
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.