[Python-Dev] PEP 273 - Import from Zip Archives

Gordon McMillan gmcm@hypernet.com
Thu, 28 Feb 2002 10:55:39 -0500


On 28 Feb 2002 at 9:44, James C. Ahlstrom wrote:

> The other objection raised at the time was the
> possible slow down of imports. 

imputil was 30 to 40% slower than C import. iu
is about 10 to 15% slower under normal usage, but
can be faster if you use archives and arrange sys.path
intelligently.
 
> I think the existing C module search code is
> basically good, although I wouldn't mind moving
> module import into a Python method.  But since the C
> works, I have little motivation to replace it. 

It works because its implementation is the
definition of what works. Note that while the
import namespace (pkg.submodule.module)
is mapped to the filesystem, the two namespaces
are not isomorphic.
 
> My code uses os.listdir to cache directory
> contents, but defers its use until the os module can
> be imported using the C import code. 

A win over some threshold of number of hits on
that directory; a loss under that threshold.

> I think a
> similar trick could be used to replace imports with
> a new module.  This would make it easy to replace
> imports.  But this would not make it easy to add
> features unless a module were available which
> implemented the current import semantics in Python. 

The only incompatibility I'm aware of in iu.py is that
it doesn't have a import lock.
 

-- Gordon
http://www.mcmillan-inc.com/