From ed29bd6530247f3097eeb6c87a99b18d168e7720 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 8 Feb 2024 00:41:27 -0800 Subject: [PATCH 1/2] Reduce import overhead of uuid module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This follows in the footsteps of #21586 This speeds up import uuid by about 6ms on Linux. Before: ``` λ hyperfine -w 4 "./python -c 'import uuid'" Benchmark 1: ./python -c 'import uuid' Time (mean ± σ): 20.4 ms ± 0.4 ms [User: 16.7 ms, System: 3.8 ms] Range (min … max): 19.6 ms … 21.8 ms 136 runs ``` After: ``` λ hyperfine -w 4 "./python -c 'import uuid'" Benchmark 1: ./python -c 'import uuid' Time (mean ± σ): 14.5 ms ± 0.3 ms [User: 11.5 ms, System: 3.2 ms] Range (min … max): 13.9 ms … 16.0 ms 175 runs ``` --- Lib/uuid.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/uuid.py b/Lib/uuid.py index 470bc0d68597ab..d4e486da15a8d7 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -53,8 +53,11 @@ __author__ = 'Ka-Ping Yee ' # The recognized platforms - known behaviors -if sys.platform in ('win32', 'darwin', 'emscripten', 'wasi'): +if sys.platform in {'win32', 'darwin', 'emscripten', 'wasi'}: _AIX = _LINUX = False +elif sys.platform == 'linux': + _LINUX = True + _AIX = False else: import platform _platform_system = platform.system() From 4dda6527d2c6e08b943900f20e73764319c50e7d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 08:51:40 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Documentation/2024-02-08-08-51-37.gh-issue-109653.QHLW4w.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2024-02-08-08-51-37.gh-issue-109653.QHLW4w.rst diff --git a/Misc/NEWS.d/next/Documentation/2024-02-08-08-51-37.gh-issue-109653.QHLW4w.rst b/Misc/NEWS.d/next/Documentation/2024-02-08-08-51-37.gh-issue-109653.QHLW4w.rst new file mode 100644 index 00000000000000..97e0c8df326d69 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2024-02-08-08-51-37.gh-issue-109653.QHLW4w.rst @@ -0,0 +1 @@ +Improve import time of :mod:`uuid` on Linux.