
On 22/07/2020 12:23 pm, Ned Batchelder wrote:
On 7/17/20 10:48 AM, Mark Shannon wrote:
Hi all,
I'd like to announce a new PEP.
It is mainly codifying that Python should do what you probably already thought it did :)
Should be uncontroversial, but all comments are welcome.
Thanks for thinking about these aspects of the interpreter, and for using the PEP process to work them out before implementation.
In the PEP, you mention, "some bytecodes will need to be marked as artificial, and not have a meaningful line number" (twice), but there's no example of what this means. Can you elaborate?
Take the simple Python function: ``` def f(cond): if cond: g() else: h() ``` which compiles to the following bytecode: 0 LOAD_FAST 0 (cond) 2 POP_JUMP_IF_FALSE 12 4 LOAD_GLOBAL 0 (g) 6 CALL_FUNCTION 0 8 POP_TOP 10 JUMP_FORWARD 6 (to 18) 12 LOAD_GLOBAL 1 (h) 14 CALL_FUNCTION 0 16 POP_TOP 18 LOAD_CONST 0 (None) 20 RETURN_VALUE Some of those instruction don't correspond to any line of code. Line number: 0 LOAD_FAST 1 2 POP_JUMP_IF_FALSE 1 4 LOAD_GLOBAL 2 6 CALL_FUNCTION 2 8 POP_TOP 2 10 JUMP_FORWARD 2 or artificial; it's debatable* 12 LOAD_GLOBAL 3 14 CALL_FUNCTION 3 16 POP_TOP 3 18 LOAD_CONST Artificial; there is no `None` in the source. 20 RETURN_VALUE Artificial; there is no `return` statement. *For practical reasons we would label this as line 2. It's faster and makes the line table more compact. Cheers, Mark.
--Ned. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/OTYRLXBR...
Code of Conduct: http://python.org/psf/codeofconduct/