Skip to content

Commit d648fc8

Browse files
committed
Reduce the number of imports for functools
1 parent 0e950dd commit d648fc8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Lib/collections/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from operator import itemgetter as _itemgetter, eq as _eq
2727
from keyword import iskeyword as _iskeyword
2828
import sys as _sys
29-
import heapq as _heapq
3029
from _weakref import proxy as _proxy
3130
from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
3231
from reprlib import recursive_repr as _recursive_repr
@@ -557,7 +556,8 @@ def most_common(self, n=None):
557556
# Emulate Bag.sortedByCount from Smalltalk
558557
if n is None:
559558
return sorted(self.items(), key=_itemgetter(1), reverse=True)
560-
return _heapq.nlargest(n, self.items(), key=_itemgetter(1))
559+
import heapq
560+
return heapq.nlargest(n, self.items(), key=_itemgetter(1))
561561

562562
def elements(self):
563563
'''Iterator over elements repeating each as many times as its count.

Lib/functools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
pass
2020
from abc import get_cache_token
2121
from collections import namedtuple
22-
from types import MappingProxyType
23-
from weakref import WeakKeyDictionary
2422
from reprlib import recursive_repr
2523
from _thread import RLock
2624

@@ -753,8 +751,10 @@ def singledispatch(func):
753751
function acts as the default implementation, and additional
754752
implementations can be registered using the register() attribute of the
755753
generic function.
756-
757754
"""
755+
from types import MappingProxyType
756+
from weakref import WeakKeyDictionary
757+
758758
registry = {}
759759
dispatch_cache = WeakKeyDictionary()
760760
cache_token = None

0 commit comments

Comments
 (0)