summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2020-07-22 11:26:37 (GMT)
committerGitHub <noreply@github.com>2020-07-22 11:26:37 (GMT)
commita18f22ab11a7bfb5ff3e74c737ca9e1bebe4abf9 (patch)
tree628a9496e662fd8cb76762f347fe8bf2d4686846 /Lib
parentf599f9ea3cdcf280cdf3a72272148895d8fcb3a4 (diff)
downloadcpython-a18f22ab11a7bfb5ff3e74c737ca9e1bebe4abf9.zip
cpython-a18f22ab11a7bfb5ff3e74c737ca9e1bebe4abf9.tar.gz
cpython-a18f22ab11a7bfb5ff3e74c737ca9e1bebe4abf9.tar.bz2
bpo-41364: Reduce import overhead of uuid module (GH-21586)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/uuid.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py
index 188e16b..9540c21 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -45,7 +45,6 @@ Typical usage:
"""
import os
-import platform
import sys
from enum import Enum
@@ -54,10 +53,13 @@ from enum import Enum
__author__ = 'Ka-Ping Yee <ping@zesty.ca>'
# The recognized platforms - known behaviors
-_AIX = platform.system() == 'AIX'
-_DARWIN = platform.system() == 'Darwin'
-_LINUX = platform.system() == 'Linux'
-_WINDOWS = platform.system() == 'Windows'
+if sys.platform in ('win32', 'darwin'):
+ _AIX = _LINUX = False
+else:
+ import platform
+ _platform_system = platform.system()
+ _AIX = _platform_system == 'AIX'
+ _LINUX = _platform_system == 'Linux'
RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [
'reserved for NCS compatibility', 'specified in RFC 4122',
@@ -688,9 +690,9 @@ def _random_getnode():
# @unittest.skipUnless(_uuid._ifconfig_getnode in _uuid._GETTERS, ...)
if _LINUX:
_OS_GETTERS = [_ip_getnode, _ifconfig_getnode]
-elif _DARWIN:
+elif sys.platform == 'darwin':
_OS_GETTERS = [_ifconfig_getnode, _arp_getnode, _netstat_getnode]
-elif _WINDOWS:
+elif sys.platform == 'win32':
_OS_GETTERS = [_netbios_getnode, _ipconfig_getnode]
elif _AIX:
_OS_GETTERS = [_netstat_getnode]