Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c4791707
Commit
c4791707
authored
Apr 04, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the localized min/max calls with normal if/else
parent
d3179a01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
Lib/collections.py
Lib/collections.py
+4
-4
No files found.
Lib/collections.py
View file @
c4791707
...
...
@@ -461,10 +461,10 @@ class Counter(dict):
'''
if
not
isinstance
(
other
,
Counter
):
return
NotImplemented
_max
=
max
result
=
Counter
()
for
elem
in
set
(
self
)
|
set
(
other
):
newcount
=
_max
(
self
[
elem
],
other
[
elem
])
p
,
q
=
self
[
elem
],
other
[
elem
]
newcount
=
q
if
p
<
q
else
p
if
newcount
>
0
:
result
[
elem
]
=
newcount
return
result
...
...
@@ -478,12 +478,12 @@ class Counter(dict):
'''
if
not
isinstance
(
other
,
Counter
):
return
NotImplemented
_min
=
min
result
=
Counter
()
if
len
(
self
)
<
len
(
other
):
self
,
other
=
other
,
self
for
elem
in
filter
(
self
.
__contains__
,
other
):
newcount
=
_min
(
self
[
elem
],
other
[
elem
])
p
,
q
=
self
[
elem
],
other
[
elem
]
newcount
=
p
if
p
<
q
else
q
if
newcount
>
0
:
result
[
elem
]
=
newcount
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment