gh-109653: Reduce the import time of random by 60% (#110221)

This commit is contained in:
Alex Waygood 2023-10-02 23:56:31 +01:00 committed by GitHub
parent 4596c76d1a
commit 21a6263020
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -65,7 +65,7 @@
try:
# hashlib is pretty heavy to load, try lean internal module first
from _sha512 import sha512 as _sha512
from _sha2 import sha512 as _sha512
except ImportError:
# fallback to official implementation
from hashlib import sha512 as _sha512

View file

@ -0,0 +1,2 @@
Fix a Python 3.12 regression in the import time of :mod:`random`. Patch by Alex
Waygood.