[issue39987] Simplify setting line numbers in the compiler

Serhiy Storchaka report at bugs.python.org
Tue Mar 17 02:54:30 EDT 2020


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

Currently the compiler can set the line number to the instruction or keep it unset (zero). Then, when create linenotab it adds entries only for set line numbers. But in rare cases (docstring or the first instruction in the module, definition of a function with default arguments, maybe more) it may add multiple entries for the same lineno even if the bytecode offset is less than 255. Seems the only effect of this is a suboptimal linenotab.

The proposed PR simplifies setting the line number in the compiler (it was the primary goal) and also fixes the above minor issue. The simplification is needed for several future changes in the compiler.

----------
components: Interpreter Core
messages: 364388
nosy: benjamin.peterson, brett.cannon, pablogsal, serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: Simplify setting line numbers in the compiler
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39987>
_______________________________________


More information about the Python-bugs-list mailing list