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

Guido van Rossum guido@python.org
Mon, 29 Oct 2001 03:37:00 -0500


> [GvR]
> 
> >Maybe it's possible to allow "/path/to/zipfile.zip/subdirectory/etc/"
> >in sys.path?  That sounds better than picking a random new character
> >as delimiter.

[Finn]
> Fine by me. From a java POV the bang ("!") was not random:
> 
> >>> import java
> >>> java.lang.Class.getResource(type(1), "/java/lang/Class.class")
> jar:file:/D:/java/jdk1.4/jre/lib/rt.jar!/java/lang/Class.class
> >>>
> 
> The URL library in java can of course open the string above as an input
> stream.

I guess the advantage of this notation is that it makes a simple check
for "file inside zip archive" possible; I sort of like that.  The
downside is that it limits the use of "!" for other reasons in
pathnames (which seems a mostly but not entirely theoretical problem).

> I assume that as long as some module exists with a __path__ like this,
> it not possible to clear the cached entries for /C/D/E/Archive.zip.

Good point.

> If importing from zip is regarded mainly as a deployment/bootstrapping
> feature, then the cleanup issues does not exist. I have no problem
> looking at it as a deployment feature (that is all I need it for
> myself), I just didn't dare to put such a limit on my jython
> implementation.

I don't see sys.path as a very dynamic thing anyway.  It gets
manipulated briefly at the beginning, and then maybe, rarely, stuff
gets added during the program run.  I've seen temporary additions, but
these were usually in the test suite.

--Guido van Rossum (home page: http://www.python.org/~guido/)