mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
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:
parent
c8cf5d7d14
commit
5e390a0fc8
2 changed files with 2 additions and 3 deletions
|
@ -3,7 +3,6 @@
|
||||||
import os as _os
|
import os as _os
|
||||||
import sys as _sys
|
import sys as _sys
|
||||||
import _thread
|
import _thread
|
||||||
import functools
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from time import monotonic as _time
|
from time import monotonic as _time
|
||||||
|
@ -1630,8 +1629,7 @@ def _register_atexit(func, *arg, **kwargs):
|
||||||
if _SHUTTING_DOWN:
|
if _SHUTTING_DOWN:
|
||||||
raise RuntimeError("can't register atexit after shutdown")
|
raise RuntimeError("can't register atexit after shutdown")
|
||||||
|
|
||||||
call = functools.partial(func, *arg, **kwargs)
|
_threading_atexits.append(lambda: func(*arg, **kwargs))
|
||||||
_threading_atexits.append(call)
|
|
||||||
|
|
||||||
|
|
||||||
from _thread import stack_size
|
from _thread import stack_size
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Reduce the import time of :mod:`threading` module by ~50%. Patch by Daniel Hollas.
|
Loading…
Add table
Add a link
Reference in a new issue