[Numpy-discussion] "import numpy" is slow
Tue Aug 5 10:51:25 CDT 2008
I just added ticket 874
which on my machine takes the import time from 0.15 seconds down to
A bit over a month ago it was about 0.33 seconds. :)
The biggest trick I didn't apply was to defer importing the re
module, and only compile the patterns when they are needed. That
would save about 0.013 seconds, but the result would be rather
fragile as people rarely consider deferring pattern definitions.
I'll submit a patch for it, expected it to be rejected. ;)
I noticed that two places import the standard Python math library,
which doesn't seem necessary:
__all__ = ['emath','math']
'math' is never used in that module. It does mean that 'numpy.math'
is the same as Python's math module, which I didn't expect. I didn't
understand why it was explicitly in the __all_ list so I didn't
change it. All tests pass without it.
size.append(math.ceil((key[k].stop - start)/
Wouldn't numpy.ceil be okay here? All tests pass when I use numpy.ceil.
This would save about 0.002 seconds, so it's a small improvement.
I think there's a subtle and minor bug in _datasource.
# Remove temp directories
Is 'rmtree' guaranteed to be present in the module scope if the
object is garbage collected during Python shutdown?
More information about the Numpy-discussion