diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index b0ea603e12a4..7276c45b7327 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -8,7 +8,6 @@ import re import sys -import platform from numpy.compat import unicode from .multiarray import dtype, array, ndarray @@ -17,7 +16,7 @@ except ImportError: ctypes = None -IS_PYPY = platform.python_implementation() == 'PyPy' +IS_PYPY = 'PyPy' in sys.version if (sys.byteorder == 'little'): _nbo = b'<' diff --git a/numpy/random/bit_generator.pyx b/numpy/random/bit_generator.pyx index eb608af6cf69..c8bea9932c0e 100644 --- a/numpy/random/bit_generator.pyx +++ b/numpy/random/bit_generator.pyx @@ -44,7 +44,9 @@ except ImportError: randbits = SystemRandom().getrandbits try: - from threading import Lock + # Threading isn't the cheapest import. Import from the lightweight + # _thread module, + from _thread import allocate_lock as Lock except ImportError: from dummy_threading import Lock