]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109653: Avoid a top-level import of `types` in `functools` (#109804)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Sun, 24 Sep 2023 16:18:27 +0000 (17:18 +0100)
committerGitHub <noreply@github.com>
Sun, 24 Sep 2023 16:18:27 +0000 (17:18 +0100)
Lib/functools.py
Misc/NEWS.d/next/Library/2023-09-24-13-28-35.gh-issue-109653.9IFU0B.rst [new file with mode: 0644]

index 6cb532323b1d67cb1cdd31bc5ad43536436316e7..55990e742bf23fda0e6917c8049e4da7a207b078 100644 (file)
@@ -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 (file)
index 0000000..c4f5a62
--- /dev/null
@@ -0,0 +1,2 @@
+Improve import time of :mod:`functools` by around 13%. Patch by Alex
+Waygood.