Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdffb909

Browse files
authored
Speed-up lazy heapq import in collections (gh-127538)
1 parentbfb0788 commitdffb909

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎Lib/collections/__init__.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
exceptImportError:
6060
pass
6161

62+
heapq=None# Lazily imported
63+
6264

6365
################################################################################
6466
### OrderedDict
@@ -633,7 +635,10 @@ def most_common(self, n=None):
633635
returnsorted(self.items(),key=_itemgetter(1),reverse=True)
634636

635637
# Lazy import to speedup Python startup time
636-
importheapq
638+
globalheapq
639+
ifheapqisNone:
640+
importheapq
641+
637642
returnheapq.nlargest(n,self.items(),key=_itemgetter(1))
638643

639644
defelements(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp