On 10/23/21 5:13 PM, Chris Angelico wrote:

> PEP: 671
> Title: Syntax for late-bound function argument defaults

I have a major concern about the utility of this addition -- it was mentioned already (sorry, I don't remember who) and I don't think it has yet been addressed.

Using the `bisect()` function as a stand-in for the 20+ years worth of Python 
APIs in existence:

    def bisect_right(a, x, lo=0, hi=None, *, key=None):
        if hi is None:
            hi = len(a)
        while lo < hi:
            ...

That function would be transformed to:

    def bisect_right(a, x, lo=0, @hi=len(a), *, key=None):
        if hi is None:
            hi = len(a)
        while lo < hi:
            ...


Notice that the `None` check is still in the body -- why? Backwards compatibility: there is code out there that actually passes in `None` for `hi`, and removing the None-check in the body will suddenly cause TypeErrors.

This seems like a lot of effort for a very marginal gain.

--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/VGCI7N3NHB4HBPKFBV2DWTJSJBRT3SGV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to