Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions www/src/Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
except ImportError:
pass

heapq = None # Lazily imported


################################################################################
### OrderedDict
Expand Down Expand Up @@ -635,9 +633,7 @@ def most_common(self, n=None):
return sorted(self.items(), key=_itemgetter(1), reverse=True)

# Lazy import to speedup Python startup time
global heapq
if heapq is None:
import heapq
import heapq

return heapq.nlargest(n, self.items(), key=_itemgetter(1))

Expand Down
5 changes: 5 additions & 0 deletions www/tests/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -3323,6 +3323,11 @@ def __getattr__(self, methodName):
import datetime
assert datetime.time(0).strftime('%I') == '12'

# issue 2620
from collections import Counter
counts = Counter(["a", "b", "a", "c", "b", "a"])
counts.most_common(1) == [("a", 3)]

# ==========================================
# Finally, report that all tests have passed
# ==========================================
Expand Down