From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 2 Oct 2023 23:31:55 +0000 (-0700) Subject: [3.12] gh-109653: Reduce the import time of `random` by 60% (GH-110221) (#110247) X-Git-Tag: v3.12.1~396 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=41e8e1553f7e4fa97265b02e18fdc2a22b6a6611;p=thirdparty%2FPython%2Fcpython.git [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 21a6263020db17020b2886f996bc23aa8cb7fbdf) Co-authored-by: Alex Waygood --- diff --git a/Lib/random.py b/Lib/random.py index 1d789b107904..1cfc2ba2f025 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -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 diff --git a/Misc/NEWS.d/next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst b/Misc/NEWS.d/next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst new file mode 100644 index 000000000000..54330976d71d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst @@ -0,0 +1,2 @@ +Fix a Python 3.12 regression in the import time of :mod:`random`. Patch by Alex +Waygood.