[Numpy-discussion] [review] Easy win to improve numpy import times by 30 %
David Cournapeau
david@ar.media.kyoto-u.ac...
Thu Oct 8 23:56:28 CDT 2009
Hi,
This branch improves numpy import times quite significantly on slow
machines:
http://github.com/cournape/numpy/tree/noinspect
One of the main culprit is ma, because of inspect (inspect is extremely
slow to import; as a data point, python -c "import inspect" takes 67 ms
vs python -c "" taking 22 ms, and python -c "import numpy" taking 158 ms
on my machine).
Since inspect is used in quite a few places, and that we only use it to
extract arguments from a function, I added a small numpy.lib.inspect
module, and change the import in numpy.ma. I copied the inspect module
of python 2.4.4 to ensure maximum compatibility. This speed up the
import times from 158 ms to 108 ms ~ 30 % speed improvement. On recent
machines, the speedup is less impressive, but still in the 20 % range.
I think it largely worths it, and will integrate this unless someone is
strongly against it or see a problem with the approach,
cheers,
David
More information about the NumPy-Discussion
mailing list