RFC: new demandimport implementation for Python 3

Gregory Szorc gregory.szorc at gmail.com
Sun Jul 17 13:41:33 EDT 2016


On Sat, Jul 16, 2016 at 3:47 PM, Siddharth Agarwal <sid at less-broken.com>
wrote:

> Hi --
>
> Earlier this week I wrote up a new demandimport implementation for
> Python 3.5 and above. I was targeting our internal binaries (we use
> Mercurial's implementation for some of our Python 2 binaries) and it
> should basically be a drop-in replacement for the one that exists in
> Mercurial.
>
> The code is at https://bpaste.net/show/f0996d3ca46f -- if now is the
> right time to submit patches for it I'd be happy to do that.
>

We definitely need to implement a lazy importer for Python 3 at some point.
The current state of Python 3 porting makes it difficult to get anything
actually running because without the lazy importer we keep tripping up on
errors from modules that aren't relevant but are imported. e.g. we can't
run `hg version` because of a failure importing hgweb modules because
something in the chain (probably commands.py) imports server code.

Is there a reason this custom loader isn't implemented in terms of
importlib.util.LazyLoader? Is the built-in lazy loader not at all suitable
for our use, requiring an independent implementation?

Given the 3.9 freeze is imminent, the right time to submit patches probably
isn't until August.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160717/7ed0c1f3/attachment.html>


More information about the Mercurial-devel mailing list