On 11/28/2016 01:01 PM, Guido van Rossum wrote:
On Mon, Nov 28, 2016 at 12:51 PM, Ethan Furman wrote:
On 11/28/2016 05:28 AM, Tomas Orsava wrote:

Rendered PEP: https://fedora-python.github.io/pep-drafts/pep-A.html 
<https://fedora-python.github.io/pep-drafts/pep-A.html>


Overall +1, but using Guido's #2 option instead for handling
 *.missing.py files (searching all possible locations for the
module before falling back to the stdlib xxx.missing.py default).

Actually the .missing.py feature would be useful for other use
 cases, so it shouldn't be limited to the stdlib part of sys.path.
 (Also I'm withdrawing my idea of searching for it while searching
 for the original .py since that would burden successful imports
 with extra stat() calls.)

Absolutely.  The key point in your counter proposal is not failing at the first 
.missing.py file possible, but rather searching all possible locations first.

If we do the full search for the import first, then a full search for the 
.missing.py, and that ends up not hurting performance at all for successful 
imports -- well, that's just icing on the cake.  :)

One "successful" use-case that would be impacted is the fallback import idiom:

try:
    # this would do two full searches before getting the error
    import BlahBlah
except ImportError:
    import blahblah

--
~Ethan~
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to