[Numpy-discussion] Adding the new polynomial/chebyshev modules.
Christopher Barker
Chris.Barker at noaa.gov
Mon Nov 16 19:05:35 EST 2009
Charles R Harris wrote:
> That's what I ended up doing. You still need to do "import
> numpy.polynomial" to get to them, they aren't automatically imported
> into the numpy namespace.
good start. This brings up a semi-off-topic question:
Is there a way to avoid importing everything when importing a module
deep in a big package? My example: we just started using
scipy.spatial.ckdtree in a project that doesn't (yet) use anything else
in scipy.
The import line:
from scipy.spatial.ckdtree import cKDTree
takes a LONG time and adds 262 modules to sys.modules
It also added 15MB to our py2exe package and who knows how much memory
it is using up.
As far as I can tell, it is perfectly functional with only ckdtree.so
and kdtree.py
Is there a solution to this short of a complete re-structuring of scipy?
-Chris
Tests:
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
mem use: 37404
>>> import sys
>>> len(sys.modules)
29
>>> import numpy
>>> len(sys.modules)
174
mem use: 45700
>>> len(sys.modules)
291
mem use: 52384
So I guess memory use isn't that bad (by modern standards!), but I'd
still rather not have 115 or so modules in there!
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list