From a9e31948424127e4ce7af551a54fd47f0b2839bb Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 2 Oct 2023 15:40:59 +0100 Subject: [PATCH 1/2] Reduce the import time of `random` by 60% --- Lib/random.py | 2 +- .../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 1d789b107904fb..1cfc2ba2f025b5 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -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 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 00000000000000..c6e0eb3294248a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst @@ -0,0 +1,2 @@ +Reduce the import time of :mod:`random` by around 60%. Patch by Alex +Waygood. From e39e4dd4d873f6137a873b23cd0bce8b186bd8fd Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 2 Oct 2023 23:29:19 +0100 Subject: [PATCH 2/2] Update Misc/NEWS.d/next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst --- .../next/Library/2023-10-02-15-40-10.gh-issue-109653.iB0peK.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index c6e0eb3294248a..54330976d71dc1 100644 --- 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 @@ -1,2 +1,2 @@ -Reduce the import time of :mod:`random` by around 60%. Patch by Alex +Fix a Python 3.12 regression in the import time of :mod:`random`. Patch by Alex Waygood.