[Numpy-discussion] "import numpy" is slow

David Cournapeau cournape@gmail....
Thu Jul 31 15:37:41 CDT 2008


On Fri, Aug 1, 2008 at 5:02 AM, Robert Kern <robert.kern@gmail.com> wrote:

>
> 5) Proxy objects ... I would really like to avoid proxy objects. They
> have caused fragility in the past.

One recurrent problem around import times optimization is that it is
some work to improve it, but it takes one line to destroy it all. For
example, inspect import came back, and this alone is ~10-15 % of my
import time on mac os x (from ~ 180 to ~160).

This would be the main advantage of lazy import; but does it really
worth the trouble, since it brings some complexity as you mentionned
last time we had this discussion ? Maybe a simple test script to check
for known costly import would be enough (running from time to time ?).

Maybe ctypes can be loaded "in the fly", too. Those are the two
obvious hotspot ( ~ 25 % altogether). with a recent SVN checkout

> 6) I'm not a fan of having environment variables control the way numpy
> gets imported, but I'm willing to consider it. For example, I might go
> for having proxy objects for linalg et al. *only* if a particular
> environment variable were set. But there had better be a very large
> improvement in import times.

linalg does not seem to have a huge impact. It is typically much
faster to load than ctypeslib or inspect.

cheers,

David


More information about the Numpy-discussion mailing list