<br><br><div class="gmail_quote">On Tue, Feb 7, 2012 at 16:19, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com">p.f.moore@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 7 February 2012 20:49, Antoine Pitrou <<a href="mailto:solipsis@pitrou.net">solipsis@pitrou.net</a>> wrote:<br>
> Well, import time is so important that the Mercurial developers have<br>
> written an on-demand import mechanism, to reduce the latency of<br>
> command-line operations.<br>
<br>
</div>One question here, I guess - does the importlib integration do<br>
anything to make writing on-demand import mechanisms easier (I'd<br>
suspect not, but you never know...) If it did, then performance issues<br>
might be somewhat less of a sticking point, as usual depending on use<br>
cases.</blockquote><div><br></div><div>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: <a href="http://code.google.com/p/importers/source/browse/importers/lazy.py">http://code.google.com/p/importers/source/browse/importers/lazy.py</a> . 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__).</div>
</div>