Skip to content

Commit 40d1de7

Browse files
authored
gh-109653: Avoid a top-level import of types in functools (#109804)
1 parent 8d365b6 commit 40d1de7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/functools.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
# import types, weakref # Deferred to single_dispatch()
2020
from reprlib import recursive_repr
2121
from _thread import RLock
22-
from types import GenericAlias
2322

23+
# Avoid importing types, so we can speedup import time
24+
GenericAlias = type(list[int])
2425

2526
################################################################################
2627
### update_wrapper() and wraps() decorator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve import time of :mod:`functools` by around 13%. Patch by Alex
2+
Waygood.

0 commit comments

Comments
 (0)