Skip to content

Commit 5554beb

Browse files
committed
No longer need to fake lazy imports
1 parent 8246d58 commit 5554beb

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

Lib/collections/__init__.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
import _collections_abc
3030
import sys as _sys
31+
lazy import copy
32+
lazy import heapq as _heapq
3133

3234
_sys.modules['collections.abc'] = _collections_abc
3335
abc = _collections_abc
@@ -59,8 +61,6 @@
5961
except ImportError:
6062
pass
6163

62-
heapq = None # Lazily imported
63-
6464

6565
################################################################################
6666
### OrderedDict
@@ -634,12 +634,7 @@ def most_common(self, n=None):
634634
if n is None:
635635
return sorted(self.items(), key=_itemgetter(1), reverse=True)
636636

637-
# Lazy import to speedup Python startup time
638-
global heapq
639-
if heapq is None:
640-
import heapq
641-
642-
return heapq.nlargest(n, self.items(), key=_itemgetter(1))
637+
return _heapq.nlargest(n, self.items(), key=_itemgetter(1))
643638

644639
def elements(self):
645640
'''Iterator over elements repeating each as many times as its count.
@@ -1249,11 +1244,10 @@ def __copy__(self):
12491244
def copy(self):
12501245
if self.__class__ is UserDict:
12511246
return UserDict(self.data.copy())
1252-
import copy
12531247
data = self.data
12541248
try:
12551249
self.data = {}
1256-
c = copy.copy(self)
1250+
c = _copy.copy(self)
12571251
finally:
12581252
self.data = data
12591253
c.update(self)

0 commit comments

Comments
 (0)