[Python-Dev] is the 'path' argument to an importer's find_module() just a hint?

Brett Cannon brett at python.org
Mon Oct 27 21:24:01 CET 2008

On Mon, Oct 27, 2008 at 12:31 PM,  <glyph at divmod.com> wrote:
> On 07:24 pm, brett at python.org wrote:
>> On Mon, Oct 27, 2008 at 3:50 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>> Brett Cannon wrote:
>> Good enough for me. Then I am just going to ignore the 'path' argument
>> for frozen modules but use it to short-circuit imports for built-in
>> modules.
> For what it's worth, Twisted uses the __path__ attribute to facilitate its
> plugin mechanism.
>  If this changes so that importing from frozen packages no
> longer honors __path__, then Twisted will no longer support plugins if the
> package to be plugged into is frozen.

But how do you manipulate it for frozen packages currently? Importing
a frozen package currently has a bad __path__ value::

  >>> import __phello__; __phello__.__path__

Notice how that is not a list. Do you special-case frozen packages?

> What is the motivation to change this?

Ease of implementation for me (this has not gone far enough to be an
official change; as of this moment this is just for my import rewrite
vaporware). imp.is_frozen() tells you whether a module is frozen or
not, and thus whether to use imp.init_frozen(). So implementing a
meta_path importer for frozen modules can be nothing more than calls
to imp.is_frozen() and imp.init_frozen() if you just ignore the 'path'


More information about the Python-Dev mailing list