[Import-SIG] Comments on the PEP 382 sprint blog post and wiki

Brett Cannon brett at python.org
Wed Jun 22 22:53:55 CEST 2011


I just finished reading Barry's blog post on the PEP 382 sprint and wanted
to make two comments.

One is about re-implementing zipimport in pure Python. I actually did a
simple implementation in my importers project:
http://code.google.com/p/importers/source/browse/importers/zip.py . It's not
optimized in any way (I have thought about this particular issue a couple of
times and always have issues deciding on how to handle caching of zipfile,
or at all), but it works (at least the last time I ran the tests =). So this
is definitely doable and a long-term goal for importlib as I want to replace
as much of the import-related code in the stdlib w/ cleaner, newer
implementations that live in the importlib namespace (e.g., zipimport,
py_compile, etc.).

Two is about the bootstrapping of importlib so as to not have to deal with
as much C code in import.c. This is my next big Python project and I
definitely want to see it happen. I have thought about this off and on for
years and have gotten as far as to create a bootstrap_importlib branch for
my hg.python.org/sandbox/bcannon repo (which is currently just an
out-of-date clone of cpython/default). I figure that getting the code loaded
can be done through using the freeze tool on importlib._bootstrap to make it
always available to the interpreter. The real sticking point in
bootstrapping though, is that importlib relies on _io which itself imports
'os' (and everything that 'os' imports). Now my hope is that in the
bootstrap code during interpreter startup the 'os' import can be postponed
until importlib is up and running, and then do a post-bootstrap init step
for _io that then import 'os' for its use (the _io module also uses the
locale module, but that is not pulled in by PyInit__io() ). Unfortunately I
have not had the time to see if postponing this import is feasible in terms
of continuing to allow _io to work for importlib; my hope is that
importlib's use of _io is simple enough it will be okay.

Anyway, if people want to help with the bootstrapping just let me know. I
will simply use this mailing list as the place to air ideas and issues that
I come across.

-Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20110622/99786ef4/attachment.html>


More information about the Import-SIG mailing list