Saizan wrote:
> BTW what would the benefit of the form "lazily import A, B"? If you
> name the modules why not import them directly? Maybe you are not sure
> you would need them, but I don't think that the overhead of importing
> them should matter..

It's primarily useful for large packages. scipy used to have a mechanism of 
postponed imports because loading all of the extension modules in all of 
scipy's 
subpackages takes a fair bit of time. It especially hurts when you only wanted 
one. However, it is quite convenient to simply write "import scipy; 
scipy.linalg.eig(matrix)".

Nonetheless, we removed that feature and stopped importing all of the 
subpackages because the postponed import mechanism interfered with a number of 
other things (namely, getting docstrings through IPython's ? operator and 
making 
py2exe apps that use scipy). Having a third-party library do the same thing 
makes interactive use nice without burdening scipy with the problems.

So, "lazily import A" would make sense if A was a large package where all of 
the 
goodies are buried in A.C.D and A.E, A.X, A.Z, etc. You *do* know that you need 
A, but you may not know what you need underneath it.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to