Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add comment about lazy import
  • Loading branch information
methane committed Sep 26, 2017
commit cac0c738cf7f45db4b43cea2afb431afad0dec6b
3 changes: 3 additions & 0 deletions Lib/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ def singledispatch(func):
implementations can be registered using the register() attribute of the
generic function.
"""
# There are many programs that use functools without singledispatch, so we
# trade-off making singledispatch marginally slower for the benefit of
# making start-up of such applications slightly faster.
from types import MappingProxyType

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is slightly faster to import types and use types.MappingProxyType once than import MappingProxyType from types. The from ... import case runs a Python code from _bootstrap.py, while the former case runs just a C code if the types module already is imported.

from weakref import WeakKeyDictionary

Expand Down