Robert Kern wrote:
>> Is there a way to avoid importing everything when importing a module
>> deep in a big package?
> 
> The package authors need to keep the __init__.py files clear. There is
> nothing you can do as a user.

I figured. so, to bring this back on-topic:

I recommend that no package imports anything it doesn't need to. It's 
just not that hard to import what you need.

numpy appears to be pretty bad in this regard:

 >>> len(sys.modules)
29
 >>> import numpy
 >>> len(sys.modules)
174

with a simple "import numpy", I get all kinds of stuff I'm unlikely to 
need in every app, and if I do, I import it anyway:

numpy.testing
numpy.ma
numpy.random
numpy.linalg
numpy.lib.financial
numpy.lib.polynomial
numpy.fft


It's probably way too late from a backward compatibility perspective to 
change any of this, but I'd love to see that cleaned up.

Maybe we can clean up scipy, though?

We could have a two-API apporach, ike what MPL has been doing. One that 
import every darn thing for ease of us on the command line, and one that 
only imports what you ask for.

-Chris


-- 
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.bar...@noaa.gov
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to