From: Alex Waygood Date: Sun, 24 Sep 2023 16:18:27 +0000 (+0100) Subject: gh-109653: Avoid a top-level import of `types` in `functools` (#109804) X-Git-Tag: v3.13.0a1~322 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40d1de758100368bce36ad7674bd937acca153bd;p=thirdparty%2FPython%2Fcpython.git gh-109653: Avoid a top-level import of `types` in `functools` (#109804) --- diff --git a/Lib/functools.py b/Lib/functools.py index 6cb532323b1d..55990e742bf2 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 000000000000..c4f5a62433a2 --- /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.