[Import-SIG] Proposal for a lazy-loading finder

Brett Cannon brett at python.org
Sat Jul 8 19:56:05 EDT 2017


At PyCon US I found out that even though I tried to minimize people using
importlib.util.LazyLoader, a bunch of people are using beyond the intended
audience which was advanced Python users such as the Mercurial team.
Knowing that people were somewhat ignoring the warnings about the dangers
of using LazyLoader, I figured it was finally time to implement a
lazy-loading finder to make sure people don't duplicate the same work and
to make sure that it is implemented properly and can change as importlib
itself does. (Plus I needed a coding break from workflow stuff while I was
stuck in the US for a conference :) .

Please have a look at
https://notebooks.azure.com/Brett/libraries/di2Btqj7zSI/html/Lazy%20importing.ipynb
and
let me know if I'm missing anything. I asked on Twitter if this would work
for Mercurial and it turns out it closely mirrors what they already do:
https://twitter.com/sid0/status/882775009051123712 (which is great since I
didn't look at their code to avoid any GPL issues even though our
relationship with the Mercurial devs is good enough to not have them sue us
over code re-use :) . With independent verification that the approach works
I'm fairly confident this can go into Python 3.7, but I still wanted to
double-check with this mailing list to make sure the API design and
approach seem sound.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20170708/a187a7dd/attachment.html>


More information about the Import-SIG mailing list