[Python-Dev] Complexity of import.c

Martin v. Löwis Martin v. Löwis
Mon, 9 Dec 2002 22:44:33 +0100


> > - Was the ExternalNames dictionary really necessary?
>
> Yikes!  that is where I record the zip file contents.  That
> avoids the linear search.

So what would have been the problem with linear search that makes this
extra data structure strictly necessary to have?

> This isn't an issue of zip importing per se.  It is the
> avoidance of phase errors during start up.  For example,
> you need a full valid sys.path to be able to import zlib.pyd
> (on Windows) so you read a compressed zip archive.  Then
> you import site.py plus whatever it imports.  This must be
> available in the zip standard lib file, so zip importing
> must already work.  Thus the need for careful bootstrapping.

I think you can't really cover all cases. For example, your patch fails
to find zlib in the Unix build tree, as the build directory is added to
sys.path only in site.py, and your patch won't attempt to import zlib
outside InitZip. So it might have been good to explain somewhere what
bootstrapping scenarios this patch is meant to support.

Regards,
Martin