[Python-Dev] What's the status of PEP 505: None-aware operators? (original) (raw)
Eric Fahlgren ericfahlgren at gmail.com
Thu Nov 30 11:08:43 EST 2017
- Previous message (by thread): [Python-Dev] What's the status of PEP 505: None-aware operators?
- Next message (by thread): [Python-Dev] What's the status of PEP 505: None-aware operators?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Nov 30, 2017 at 2:48 AM, Andrea Griffini <agriff at tin.it> wrote:
Not really related but the PEP says that arguments in Python are evaluated before the function (as a reason to reject the idea of None-aware function call) but this is not the case:
I think you're missing something here, since it seems clear to me that indeed the arguments are evaluated prior to the function call. Maybe unrolling it would help? This is equivalent to the body of your lambda, and you can see that the argument is evaluated prior to the call which receives it.
func = f() arg = g() func(arg)
>>> import dis
>>> dis.dis(lambda : f()(g())) 1 0 LOADGLOBAL 0 (f) 3 CALLFUNCTION 0
Call 'f()' with all of its arguments evaluated prior to the call (there are none, that's the '0' on the CALL_FUNCTION operator).
6 LOADGLOBAL 1 (g) 9 CALLFUNCTION 0
Next, evaluate the arguments for the next function call. Call 'g()' with all of its arguments evaluated.
12 CALLFUNCTION 1
Call the function that 'f()' returned with its argument ('g()') evaluated. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171130/ea28c765/attachment.html>
- Previous message (by thread): [Python-Dev] What's the status of PEP 505: None-aware operators?
- Next message (by thread): [Python-Dev] What's the status of PEP 505: None-aware operators?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]