On Wed, 1 Dec 2021 at 06:19, Chris Angelico <ros...@gmail.com> wrote: > > I've just updated PEP 671 https://www.python.org/dev/peps/pep-0671/ > with some additional information about the reference implementation, > and some clarifications elsewhere. > > *PEP 671: Syntax for late-bound function argument defaults* > > Questions, for you all: > > 1) If this feature existed in Python 3.11 exactly as described, would > you use it?
Probably not. Mainly because I don't have any real use for it rather than because I have any inherent problem with it (but see below, the more I thought about it the more uncomfortable with it I became). > 2) Independently: Is the syntactic distinction between "=" and "=>" a > cognitive burden? > > (It's absolutely valid to say "yes" and "yes", and feel free to say > which of those pulls is the stronger one.) Not especially. The idea of having both late-bound and early-bound parameters is probably more of a cognitive burden than the syntax. > 3) If "yes" to question 1, would you use it for any/all of (a) mutable > defaults, (b) referencing things that might have changed, (c) > referencing other arguments, (d) something else? N/A, except to say that when you enumerate the use cases like this, none of them even tempt me to use this feature. I think that the only thing I might use it for is to make it easier to annotate defaults (as f(a: list[int] => []) rather than as f(a: list[int] | None = None). So I'll revise my answer to (1) and say that I *might* use this, but only in a way it wasn't intended to be used in, and mostly because I hate how verbose it is to express optional arguments in type annotations. (And the fact that the annotation exposes the sentinel value, even when you want it to be opaque). I hope I don't succumb and do that, though ;-) > 4) If "no" to question 1, is there some other spelling or other small > change that WOULD mean you would use it? (Some examples in the PEP.) Not really. It addresses a wart in the language, but on consideration, it feels like the cure is no better than the disease. > 5) Do you know how to compile CPython from source, and would you be > willing to try this out? Please? :) Sorry, I really don't have time to, in the foreseeable future. If I did have time, one thing I would experiment with is how this interacts with typing and tools like pyright and mypy (yes, I know type checkers would need updating for the new syntax, so that would mostly be a thought experiment) - as I say, I'd expect to annotate a function with an optional list argument defaulting to an empty list as f(a: list[int] => []), which means that __annotations__ needs to distinguish between this case and f(a: list[int]) with no default. >>> def f(a: list[int]): pass ... >>> f.__annotations__ {'a': list[int]} >>> def f(a: list[int] => []): pass ... >>> f.__annotations__ ??? > I'd love to hear, also, from anyone's friends/family who know a bit of > Python but haven't been involved in this discussion. If late-bound > defaults "just make sense" to people, that would be highly > informative. Sorry, I don't have any feedback like that. What I can say, though, is I'd find it quite hard to express the question, in the sense that I'd struggle to explain the difference between early and late bound parameters to a non-expert, much less explain why we need both. I'd probably just say "it's short for a default of None and a check" which doesn't really capture the point... > Any and all comments welcomed. I mean, this is python-ideas after > all... bikeshedding is what we do best! I hope this was useful feedback. Paul _______________________________________________ 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/BMJLEOHEA7MYC5IPYUSXELPRWGW4VG6M/ Code of Conduct: http://python.org/psf/codeofconduct/