[Import-SIG] PEP 382 as an import hook

Eric Snow ericsnowcurrently at gmail.com
Mon Jun 27 04:52:52 CEST 2011


Would a PEP 302 import hook to implement PEP 382 be too inefficient?
What about just for testing out the PEP?  Maybe I'm missing something,
but it seems like it should be doable and would enable PEP 382 for
2.x.

It would have to:

1. handle adding the find_path and load_module_with_path calls,
2. handle augmenting importlib's _DefaultPathFinder or an equivalent
to handle the .pth files.

I'll probably take a stab at writing one up in the next week or two,
regardless.  It's actually a pretty similar use case to another
project I am working on.  I'll admit that without importlib the second
part will require some messiness.  The import engine would be helpful
too.

Alternately you could replace sys.metapath with a subclass of list
that effectively wraps each loader added to it with similar
functionality to the above finder.

-eric


More information about the Import-SIG mailing list