[Python-Dev] Getting importlib into the standard library for 3.1

Brett Cannon brett at python.org
Thu Jan 8 20:06:53 CET 2009

My work rewriting import in pure Python code has reached beta.
Basically the code is semantically complete and as
backwards-compatible as I can make it short of widespread testing or
running on a Windows box. There are still some tweaks here and there I
want to make and an API to expose, but __import__ works as expected
when run as the import implementation for all unit tests.

Knowing how waiting for perfection leads to never finishing, I would
like to start figuring out what it will take to get the code added to
the standard library of 3.1 with hopes of getting the bootstrapping
stuff done so that the C implementation of import can go away in 3.1
as well. I see basically three things that need to be decided upfront.

One, does anyone have issues if I check in importlib? We have
typically said code has to have been selected as best-of-breed by the
community first, so I realize I am asking for a waiver on this one.

Two, what should the final name be? I originally went with importlib
since this code was developed outside of the trunk, but I can see some
people suggesting using the imp name. That's fine although that does
lead to the question of what to do with the current imp. It could be
renamed _imp, but then that means what is currently named _importlib
would have to be renamed to something else as well. Maybe
imp._bootstrap? Plus I always viewed imp as the place where really
low-level, C-based stuff lived. Otherwise importlib can slowly subsume
the stuff in imp that is still useful.

Three, there are still some structural changes to the code that I want
to make. I can hold off on checking in the code until these changes
are made, but as I said earlier, I know better than to wait forever
for perfection.

And because I know people will ask: no, I do not plan to backport all
the code to 2.7. I want this to be a carrot to people to switch to
3.x. But I will backport the import_module function I wrote to 2.7 so
people do have that oft-requested feature since it is a really simple
bit of Python code.


More information about the Python-Dev mailing list