[Python-Dev] requirements for moving __import__ over to importlib?

Brett Cannon brett at python.org
Tue Feb 7 23:21:20 CET 2012


On Tue, Feb 7, 2012 at 16:19, Paul Moore <p.f.moore at gmail.com> wrote:

> On 7 February 2012 20:49, Antoine Pitrou <solipsis at pitrou.net> wrote:
> > Well, import time is so important that the Mercurial developers have
> > written an on-demand import mechanism, to reduce the latency of
> > command-line operations.
>
> One question here, I guess - does the importlib integration do
> anything to make writing on-demand import mechanisms easier (I'd
> suspect not, but you never know...) If it did, then performance issues
> might be somewhat less of a sticking point, as usual depending on use
> cases.


Depends on what your feature set is. I have a fully working mixin you can
add to any loader which makes it lazy if you trigger the import on reading
an attribute from the module:
http://code.google.com/p/importers/source/browse/importers/lazy.py . But if
you want to trigger the import on *writing* an attribute then I have yet to
make that work in Python source (maybe people have an idea on how to make
that work since __setattr__ doesn't mix well with __getattribute__).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120207/f965ba80/attachment.html>


More information about the Python-Dev mailing list