[Python-Dev] importlib is now bootstrapped (and what that means)

Brett Cannon brett at python.org
Sat Apr 14 20:12:48 CEST 2012

My multi-year project -- started in 2006 according to my blog -- to rewrite
import in pure Python and then bootstrap it into CPython as *the*
implementation of __import__() is finally over (mostly)! Hopefully I didn't
break too much code in the process. =)

Now this is "mostly" finished because the single incompatibility that
importlib has is that it doesn't check the Windows registry for paths to
search since I lack a Windows installation to develop and test on. If
someone can tackle that issue that would be greatly appreciated (

Next up is how to maintain/develop for all of this. So the Makefile will
regenerate Python/importlib.h whenever Lib/importlib/_bootstrap.py or
Python/freeze_importlib.py changes. So if you make a change to importlib
make sure to get it working and tested before running 'make' again else you
will generate a bad frozen importlib (if you do mess up you can also revert
the changes to importlib.h and re-run make; a perk to having importlib.h
checked in). Otherwise keep in mind that you can't use any module that
isn't a builtin (sys.builtin_module_names) in importlib._bootstrap since
you can't import something w/o import working. =)

Where does this leave imp and Python/import.c? I want to make imp into _imp
and then implement as much as possible in pure Python (either in importlib
itself or in Lib/imp.py). Once that has happened then more C code in
import.c can be gutted (see http://bugs.python.org/issue13959 for tracking
this work which I will start piecemeal shortly).

I have some ideas on how to improve things for import, but I'm going to do
them as separate emails to have separate discussion threads on them so all
of this is easier to follow (e.g. actually following through on PEP 302 and
exposing the import machinery as importers instead of having anything be
implicit, etc.).

And the only outstanding point of contention in all of this is that some
people don't like having freeze_importlib.py in Python/ and instead want it
in Tools/. I didn't leave it in Tools/ as I have always viewed that Python
should build w/o the Tools directory, but maybe the Linux distros actually
ship with it and thus this is an unneeded worry. Plus the scripts to
generate the AST are in Parser so there is precedent for what I have done.

Anyway, I will write up the What's New entry and double-check the language
spec for updating once all of the potential changes I want to talk about in
other emails have been resolved.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120414/4c48cd4e/attachment.html>

More information about the Python-Dev mailing list