[Numpy-discussion] "import numpy" is slow

Andrew Dalke dalke@dalkescientific....
Tue Jul 1 05:53:02 CDT 2008


2008/7/1 Hanni Ali <hanni.ali@gmail.com>:
> Would it not be possible to import just the necessary module of  
> numpy to
> meet the necessary functionality of your application.

Matthieu Brucher responded:
> IIRC, il you do import numpy.core as numpy, it starts by importing
> numpy, so it will be even slower.

which you can see if you start python with the "-v" option to display  
imports.

 >>> import numpy.core
import numpy # directory /Library/Frameworks/Python.framework/ 
Versions/2.5/lib/python2.5/site-packages/numpy
# /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ 
site-packages/numpy/__init__.pyc matches /Library/Frameworks/ 
Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/ 
__init__.py
import numpy # precompiled from /Library/Frameworks/Python.framework/ 
Versions/2.5/lib/python2.5/site-packages/numpy/__init__.pyc
# /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ 
site-packages/numpy/__config__.pyc matches /Library/Frameworks/ 
Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/ 
__config__.py
import numpy.__config__ # precompiled from /Library/Frameworks/ 
Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/ 
__config__.pyc

   ...
and many more


				Andrew
				dalke@dalkescientific.com




More information about the Numpy-discussion mailing list