From 21a6263020db17020b2886f996bc23aa8cb7fbdf Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 2 Oct 2023 23:56:31 +0100 Subject: gh-109653: Reduce the import time of `random` by 60% (#110221) --- Lib/random.py | 2 +- Misc/NEWS.d/next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst diff --git a/Lib/random.py b/Lib/random.py index 1d789b1..1cfc2ba 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 0000000..5433097 --- /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. -- cgit v0.12