[Numpy-discussion] "import numpy" performance
Ralf Gommers
ralf.gommers@googlemail....
Thu Jul 5 11:38:53 CDT 2012
On Tue, Jul 3, 2012 at 1:16 AM, Andrew Dalke <dalke@dalkescientific.com>wrote:
> On Jul 3, 2012, at 12:46 AM, David Cournapeau wrote:
> > It is indeed irrelevant to your end goal, but it does affect the
> > interpretation of what import_array does, and thus of your benchmark
>
> Indeed.
>
> > Focusing on polynomial seems the only sensible action. Except for
> > test, all the other stuff seem difficult to change without breaking
> > anything.
>
> I confirm that when I comment out numpy/__init__.py's "import polynomial"
> then the import time for numpy.core.multiarray goes from
>
> 0.084u 0.031s 0:00.11 100.0% 0+0k 0+0io 0pf+0w
>
> to
>
> 0.058u 0.028s 0:00.08 87.5% 0+0k 0+0io 0pf+0w
>
>
> numpy/polynomial imports:
> from polynomial import Polynomial
> from chebyshev import Chebyshev
> from legendre import Legendre
> from hermite import Hermite
> from hermite_e import HermiteE
> from laguerre import Laguerre
>
> and there's no easy way to make these be lazy imports.
>
>
> Strange! The bottom of hermite.py has:
>
> exec polytemplate.substitute(name='Hermite', nick='herm', domain='[-1,1]')
>
> as well as similar code in laguerre.py, chebyshev.py, hermite_e.py,
> and polynomial.py.
>
> I bet there's a lot of overhead generating and exec'ing
> those for each import!
>
Looks like it. That could easily be done at build time though. Making that
change and your proposed change to the test functions, which seems fine,
will likely be enough to reach your 40% target. No need for new imports or
lazy loading then I hope.
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120705/1f5003f3/attachment.html
More information about the NumPy-Discussion
mailing list