[Python-Dev] Another approach for the import mechanism

Martin v. Löwis martin@v.loewis.de
06 Dec 2002 07:25:37 +0100


Gustavo Niemeyer <niemeyer@conectiva.com> writes:

> > So you can have only a single multi-file non-package zipfile in each
> > directory on sys.path? I find this quite ugly: a directory with only a
> 
> Well, with the current implementation you'll only allow one single
> multi-file non-package zipfile in each entry of sys.path. :-)

Yes, but I don't have to clutter my disk for that.

> - Don't have to change path to use compressed packages (at least
>   not if you want to provide compressed packages, individual
>   compressed modules or the standard library).

I thought you just explained that I will need to change the path to
provide a compressed standard library, to point to a directory that
contains an __init__.zip.

> - Don't have to specify the compression type hardcoded.

I don't understand that remark. If I have a zipfile, I surely must
install a zipfile hook in your approach also - a .tar.bz2 hook won't
be able to load the zipfile, no?

> - Allows one to ship a package inside a zip file, without asking
>   the user to change his path, and without hacking the package.
> 
> - Allows one to compress a single file (foobar.py.bz2).

This is really the same issue: If you had a mechanism to import a
module from a .py.bz2 file, you could use the same mechanism to import
a package (or subpackage) from a .zip file. While I think this might
be desirable, I also think it was never the goal of PEP 273 to provide
such a facility.

Regards,
Martin