[Python-Dev] Zip imports, PEP 273, and the .zip extension

Martin v. Löwis martin@v.loewis.de
07 Dec 2002 18:26:30 +0100


Paul Moore <lists@morpheus.demon.co.uk> writes:

> Any comments?

That's quite expensive. Unless I'm mistaken, it causes an additional
stat call per sys.path item (to find out that it is a directory).

If Just's patch is accepted, you get that feature for free

import zipimport,sys
sys.path.append(zipimport.zipimporter(sys.argv[0]))

does what you want. For Jim's patch, I'd say you lose: We should
tighten the PEP saying that only items in sys.path are treated as
zipfiles that have ".zip" in their name (with a yet-to-be-specified
separator for putting directory in the zipfile into sys.path).

Regards,
Martin