[Numpy-discussion] "import numpy" performance
David Cournapeau
cournape at gmail.com
Mon Jul 2 18:46:41 EDT 2012
On Mon, Jul 2, 2012 at 11:15 PM, Andrew Dalke <dalke at dalkescientific.com> wrote:
> On Jul 2, 2012, at 11:38 PM, Fernando Perez wrote:
>> No, that's the wrong thing to test, because it effectively amounts to
>> 'import numpy', sicne the numpy __init__ file is still executed. As
>> David indicated, you must import multarray.so by itself.
>
> I understand that clarification. However, it does not affect me.
It is indeed irrelevant to your end goal, but it does affect the
interpretation of what import_array does, and thus of your benchmark
polynomial is definitely the big new overhead (I don't remember it
being significant last time I optimized numpy import times), it is
roughly 30 % of the total cost of importing numpy (95 -> 70 ms total
time, of which numpy went from 70 to 50 ms). Then ctypeslib and test
are the two other significant ones.
I use profile_imports.py from bzr as follows:
import sys
import profile_imports
profile_imports.install()
import numpy
profile_imports.log_stack_info(sys.stdout)
Focusing on polynomial seems the only sensible action. Except for
test, all the other stuff seem difficult to change without breaking
anything.
David
More information about the NumPy-Discussion
mailing list