Skip to content

Commit 68b8fff

Browse files
authored
gh-109653: Reduce import overhead of uuid module on Linux (#115160)
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 ```
1 parent 0876b92 commit 68b8fff

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/uuid.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@
5353
__author__ = 'Ka-Ping Yee <[email protected]>'
5454

5555
# The recognized platforms - known behaviors
56-
if sys.platform in ('win32', 'darwin', 'emscripten', 'wasi'):
56+
if sys.platform in {'win32', 'darwin', 'emscripten', 'wasi'}:
5757
_AIX = _LINUX = False
58+
elif sys.platform == 'linux':
59+
_LINUX = True
60+
_AIX = False
5861
else:
5962
import platform
6063
_platform_system = platform.system()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve import time of :mod:`uuid` on Linux.

0 commit comments

Comments
 (0)