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

Eric Snow ericsnowcurrently at gmail.com
Fri Apr 20 17:02:14 CEST 2012

On Fri, Apr 20, 2012 at 7:54 AM, Eric V. Smith <eric at trueblade.com> wrote:
> On 04/14/2012 02:12 PM, Brett Cannon wrote:
>> 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)!
> Maybe I'm missing something, but it seems that I need to run
> importlib._bootstrap._install(sys, _imp) manually in order to make
> __import__ be importlib's version. Is that not supposed to happen
> automatically?

In the default tip (3.3a2+), importlib.__import__ is already
bootstrapped, so you don't need mess with anything.  As well, in any
of the 3.x versions you can bind builtins.__import__ to

If you are making changes to importlib (essentially, changes in
Lib/importlib/_bootstrap.py), you must re-build (make) cpython in
order for your changes to get pulled into the frozen copy of
importlib.  Until you do that, the built-in import machinery will be
the one that existed before your changes.  You could also re-bind
builtins.__import__ to try out the changes without having to re-build,
but ultimately your changes will have to get frozen (into
Python/importlib.h) and will be part of the commit of your changes to

Likely you already know all this, but just in case...  :)


More information about the Python-Dev mailing list