[Python-Dev] PEP 511 (code transformers) rejected

Victor Stinner victor.stinner at gmail.com
Thu Nov 2 09:42:31 EDT 2017


(Email resent, I first sent it to Nick privately by mistake.)

2017-11-02 2:53 GMT+01:00 Nick Coghlan <ncoghlan at gmail.com>:
> The piece that we're currently missing to make such workflows easier to
> manage is an equivalent of JavaScript's source maps (...)

Code objects already have a instruction pointer => line number mapping
table: the code.co_lnotab field. It's documented at:
https://github.com/python/cpython/blob/master/Objects/lnotab_notes.txt

This table is built from the line number information of the AST tree.

The mapping table is optimized to be small. Before Python 3.5, line
number had to be monotonic. Since Python 3.6, you "move" instructions
at the AST level, and so have "non-monotonic" line numbers (ex: line
1, line 3, line 2, line 4).

Victor


More information about the Python-Dev mailing list