gh-109653: Fix regression in the import time of `random` in Python 3.12 (GH-110221)
(cherry picked from commit
21a6263020db17020b2886f996bc23aa8cb7fbdf)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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
--- /dev/null
+Fix a Python 3.12 regression in the import time of :mod:`random`. Patch by Alex
+Waygood.