[Numpy-discussion] NumPy 1.2.0b2 released
Charles R Harris
Fri Aug 15 12:12:45 CDT 2008
On Fri, Aug 15, 2008 at 10:41 AM, Andrew Dalke <email@example.com>wrote:
> On Aug 15, 2008, at 4:38 PM, Pauli Virtanen wrote:
> > I think you can still do something evil, like this:
> > import os
> > if os.environ.get('NUMPY_VIA_API', '0') != '0':
> > from numpy.lib.fromnumeric import *
> > ...
> > But I'm not sure how many milliseconds must be gained to justify
> > this...
> I don't think it's enough. I don't like environmental
> variable tricks like that. My tests suggest:
> current SVN: 0.12 seconds
> my patch: 0.10 seconds
> removing some top-level imports: 0.09 seconds
> my patch and removing some
> additional top-level imports: 0.08 seconds (this is a guess)
> First, I reverted my patch, so my import times went from
> 0.10 second to 0.12 seconds.
> Second, I commented out the pure module imports from numpy/__init__.py
> import linalg
> import fft
> import random
> import ctypeslib
> import ma
> import doc
> The import time went to 0.089. Note that my patch also
> gets rid of "import doc" and "import ctypeslib", which
> take up a good chunk of time. The fft, linalg, and
> random libraries take 0.002 seconds each, and ma takes 0.007.
> Not doing these imports makes code about 0.01 second
> faster than my patches, which shaved off 0.02 seconds.
> That 0.01 second comes from not importing the
> fft, linalg, and ma modules.
> My patch does improve things in a few other places, so
> perhaps those other places adds another 0.01 seconds
> of performance.
> Why can't things be better? Take a look at the slowest
> imports. (Note, times are inclusive of the children)
> == Slowest (including children) ==
> 0.089 numpy (None)
> 0.085 add_newdocs (numpy)
> 0.079 lib (add_newdocs)
> 0.041 type_check (lib)
> 0.040 numpy.core.numeric (type_check)
> 0.015 _internal (numpy.core.numeric)
> 0.014 numpy.testing (lib)
> 0.014 re (_internal)
> 0.010 unittest (numpy.testing)
> 0.010 numeric (numpy.core.numeric)
> 0.009 io (lib)
> Most of the time is spent importing 'lib'.
> Can that be made quicker? Not easily. "lib" is
> first imported in "add_newdocs". Personally, I
> want to get rid of add_newdocs and move the
> docstrings into the correct locations.
And those would be? I hope you aren't thinking of moving them into the C
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion