diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-09-24 16:18:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-24 16:18:27 (GMT) |
commit | 40d1de758100368bce36ad7674bd937acca153bd (patch) | |
tree | 6f8c8fc443b8dc540a79c3d7249f5e62a85904e6 | |
parent | 8d365b60bacf0a7edda24eba2d45aba1c2626fbc (diff) | |
download | cpython-40d1de758100368bce36ad7674bd937acca153bd.zip cpython-40d1de758100368bce36ad7674bd937acca153bd.tar.gz cpython-40d1de758100368bce36ad7674bd937acca153bd.tar.bz2 |
gh-109653: Avoid a top-level import of `types` in `functools` (#109804)
-rw-r--r-- | Lib/functools.py | 3 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2023-09-24-13-28-35.gh-issue-109653.9IFU0B.rst | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 6cb5323..55990e7 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -19,8 +19,9 @@ from collections import namedtuple # import types, weakref # Deferred to single_dispatch() from reprlib import recursive_repr from _thread import RLock -from types import GenericAlias +# Avoid importing types, so we can speedup import time +GenericAlias = type(list[int]) ################################################################################ ### update_wrapper() and wraps() decorator diff --git a/Misc/NEWS.d/next/Library/2023-09-24-13-28-35.gh-issue-109653.9IFU0B.rst b/Misc/NEWS.d/next/Library/2023-09-24-13-28-35.gh-issue-109653.9IFU0B.rst new file mode 100644 index 0000000..c4f5a62 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-09-24-13-28-35.gh-issue-109653.9IFU0B.rst @@ -0,0 +1,2 @@ +Improve import time of :mod:`functools` by around 13%. Patch by Alex +Waygood. |