[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 21a6263020)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-10-02 16:31:55 -07:00 committed by GitHub
parent 892b1942a7
commit 41e8e1553f
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 @@ import _random
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