Serhiy Storchaka added the comment:
collections is very popular module. It is almost impossible to avoid importing
it since so much stdlib modules use namedtuple, OrderedDict, deque, or
defaultdict. The reason of moving a heapq import inside a Counter method is
that importing heapq adds two entries in sys.modules ('heapq' and '_heapq'),
but it is needed only when Counter.most_common() is called with non-default
argument. The Counter class is less used than other four popular collections
classes, not every use of the Counter class involves using of the most_common()
method, and the most_common() method not always is called with argument
(actually it is used only twice in the stdlib, in both cases without argument).
I'll remove this change if you say this, but this will decrease the effect of
this patch from 10 to 8 modules.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue30152>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com