[Numpy-discussion] slow import of numpy modules

David Cournapeau cournapeau@cslab.kecl.ntt.co...
Wed Jul 2 23:56:01 CDT 2008


On Wed, 2008-07-02 at 23:36 -0500, Robert Kern wrote:
> 
> Neither one has participated in this thread. At least, no such email
> has made it to my inbox.

This was in the thread "import numpy" is slow, I mixed the two, sorry.

> 
> I think it's worth moving these imports into the functions, then.

Ok, will do it, then.

> 
> > Then, something which takes a awful lot of time is finfo to get floating
> > points limits. This takes like 30-40 ms. I wonder if there are some ways
> > to make it faster. After that, there is no obvious spot I remember, but
> > I can get them tonight when I go back to my lab.
> 
> They can all be turned into properties that look up in a cache first.
> iinfo already does this.

Yes, it is cached, but the first run is slow and seems to take a long
time. As it is used as a default argument in numpy.ma.extras, it is run
when you import numpy. Just to check, I set the default argument to
None, and now import numpy is ~85ms instead of 180ms. 40ms to get the
tiny attribute of float sounds slow, but maybe there is no way around it
(maybe MachAr can be sped up a bit, but this looks like quite sensitive
code).

cheers,

David



More information about the Numpy-discussion mailing list