gh-109653: Speedup import of threading module (#114509)

Avoiding an import of functools leads to 50% speedup of import time.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Daniel Hollas 2024-01-31 09:29:44 +00:00 committed by GitHub
parent c8cf5d7d14
commit 5e390a0fc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View file

@ -3,7 +3,6 @@
import os as _os
import sys as _sys
import _thread
import functools
import warnings
from time import monotonic as _time
@ -1630,8 +1629,7 @@ def _register_atexit(func, *arg, **kwargs):
if _SHUTTING_DOWN:
raise RuntimeError("can't register atexit after shutdown")
call = functools.partial(func, *arg, **kwargs)
_threading_atexits.append(call)
_threading_atexits.append(lambda: func(*arg, **kwargs))
from _thread import stack_size

View file

@ -0,0 +1 @@
Reduce the import time of :mod:`threading` module by ~50%. Patch by Daniel Hollas.