Skip to content

Commit 41e8e15

Browse files
[3.12] gh-109653: Reduce the import time of random by 60% (GH-110221) (#110247)
gh-109653: Fix regression in the import time of `random` in Python 3.12 (GH-110221) (cherry picked from commit 21a6263) Co-authored-by: Alex Waygood <[email protected]>
1 parent 892b194 commit 41e8e15

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/random.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
try:
6767
# hashlib is pretty heavy to load, try lean internal module first
68-
from _sha512 import sha512 as _sha512
68+
from _sha2 import sha512 as _sha512
6969
except ImportError:
7070
# fallback to official implementation
7171
from hashlib import sha512 as _sha512
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a Python 3.12 regression in the import time of :mod:`random`. Patch by Alex
2+
Waygood.

0 commit comments

Comments
 (0)