[Python-Dev] New and Improved Import Hooks
Samuele Pedroni
pedronis@bluewin.ch
Tue, 3 Dec 2002 22:44:48 +0100
From: "Just van Rossum" <just@letterror.com>
> Samuele Pedroni wrote:
>
> > No jython accepts strings of the form *.zip in sys.path, that are
> > converted upon scanning on import to string subclasses' instances
> > with the same value as string, through which import happens using an
> > internal interface implemented by these string subclasses.
> >
> > We also set __path__s to contain things of the form
*.zip/rel/path/to/package.
>
> And these package __path__s are _also_ "import hook" string subclasses,
right?
Yes
The interface is internal because here was no CPython prior art, and because we
also support importing java classes from sys.path (both from dirs and zipfiles,
although there are some bugs wrt to the latter), and our import code also begs
for some refactoring... so things are in flux.
[In the future (2.2) we were planning to add support for Java ClassLoaders too,
but it is still unclear whether to put them in sys.path makes sense or not. I'm
reporting this not because Java ClassLoaders are relevant to CPython but to
point out that probably not all import hooks can be sys.path centered, and then
a question is whether they should be considered before or after sys.path ]
regards.