Skip to content

Commit

Permalink
Improvements to import time
Browse files Browse the repository at this point in the history
  • Loading branch information
robbmcleod committed Oct 24, 2017
1 parent cbc4c36 commit d4b5b6e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
8 changes: 2 additions & 6 deletions numexpr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@
else:
use_vml = False

from cpuinfo import cpu

if cpu.is_AMD() or cpu.is_Intel():
is_cpu_amd_intel = True
else:
is_cpu_amd_intel = False
# cpuinfo imports were moved into the test submodule function that calls them
# to improve import times.

import os, os.path
import platform
Expand Down
8 changes: 5 additions & 3 deletions numexpr/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import threading

import numpy
from pkg_resources import parse_version
_np_version = parse_version(numpy.__version__)
# numpy's behavoir sometimes changes with versioning, especially in regard as
# to when ints are cast to floats.
# _np_version will be similar to ('1', '13', '1') for which we can use simple comparisons
_np_version = tuple( ver for ver in numpy.__version__.split('.') )

# Declare a double type that does not exist in Python space
double = numpy.double
Expand Down Expand Up @@ -281,7 +283,7 @@ def rtruediv_op(a, b):

@ophelper
def pow_op(a, b):
if (_np_version >= parse_version('1.12.0b1') and
if (_np_version >= ('1', '12', '0b1') and
b.astKind in ('int', 'long') and
a.astKind in ('int', 'long') and
numpy.any(b.value < 0)):
Expand Down
3 changes: 2 additions & 1 deletion numexpr/necompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import numpy
import threading

from numexpr import interpreter, expressions, use_vml, is_cpu_amd_intel
# from numexpr import interpreter, expressions, use_vml, is_cpu_amd_intel
from numexpr import interpreter, expressions, use_vml
from numexpr.utils import CacheDict

# Declare a double type that does not exist in Python space
Expand Down
9 changes: 8 additions & 1 deletion numexpr/tests/test_numexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,13 @@ def test_multiprocess(self):
def print_versions():
"""Print the versions of software that numexpr relies on."""
from pkg_resources import parse_version
from numexpr.cpuinfo import cpu

if cpu.is_AMD() or cpu.is_Intel():
is_cpu_amd_intel = True
else:
is_cpu_amd_intel = False

if parse_version(np.__version__) < parse_version(minimum_numpy_version):
print("*Warning*: NumPy version is lower than recommended: %s < %s" % \
(np.__version__, minimum_numpy_version))
Expand All @@ -1016,7 +1023,7 @@ def print_versions():
if os.name == 'posix':
(sysname, nodename, release, version, machine) = os.uname()
print('Platform: %s-%s' % (sys.platform, machine))
print("AMD/Intel CPU? %s" % numexpr.is_cpu_amd_intel)
print("AMD/Intel CPU? %s" % is_cpu_amd_intel)
print("VML available? %s" % use_vml)
if use_vml:
print("VML/MKL version: %s" % numexpr.get_vml_version())
Expand Down

0 comments on commit d4b5b6e

Please sign in to comment.