Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9] bpo-41364: Reduce import overhead of uuid module (GH-21586) #21589

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Lib/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"""

import os
import platform
import sys

from enum import Enum
Expand All @@ -54,10 +53,13 @@
__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'

_MAC_DELIM = b':'
_MAC_OMITS_LEADING_ZEROES = False
Expand Down Expand Up @@ -618,9 +620,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':
# bpo-40201: _windll_getnode will always succeed, so these are not needed
_OS_GETTERS = []
elif _AIX:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce import overhead of :mod:`uuid`.