[Python-Dev] Re: Accepting PEP 626

2020年10月29日 06:34:04 -0700

Hi Pablo,
On 29/10/2020 11:08 am, Pablo Galindo Salgado wrote:
 > The new semantics may well result in some slowdowns. That's stated in
the PEP.I don't think I can reliably isolate the effects of the (very slight)
change in the behavior of f_lineno.
Ok, then let's make at least we measure the general slowdowns.
Except that we can't measure the performance of a specification.
We can only measure the performance of entire implementations.
I can make an implementation that conforms to PEP 626 that is slower than master, or I can make one that's faster :)
It doesn't change the value of the PEP itself.
Let me give you a toy example.
def f():
 while 1:
 body()
3.9 compiles this to:
(The trailing, implicit return has been stripped for clarity)
 3 >> 0 LOAD_GLOBAL 0 (body)
 2 CALL_FUNCTION 0
 4 POP_TOP
 6 JUMP_ABSOLUTE 0
A naive implementation that conforms to PEP 626 would this compile to:
 2 >> 0 NOP
 3 2 LOAD_GLOBAL 0 (body)
 4 CALL_FUNCTION 0
 6 POP_TOP
 8 JUMP_ABSOLUTE 0
But a better implementation could produce this:
 2 0 NOP
 3 >> 2 LOAD_GLOBAL 0 (body)
 4 CALL_FUNCTION 0
 6 POP_TOP
 2 8 JUMP_ABSOLUTE 2
Which has the same bytecodes as 3.9 in the loop, and has the correct line numbers.
Cheers,
Mark.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/A6RRMIGXVHV7I7QMG42BCD6K4AJBKVST/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to