This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Allow zero-width entries in code.co_lines()
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.10
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Mark.Shannon, pablogsal, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-12-22 12:02 by Mark.Shannon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (1)
msg383585 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2020-12-22 12:02
While the impact of making `if 0` and `while True` appear when tracing can be mitigated, the impact of `continue` is more of a concern.

The following loop:

while True:
    if test:

PEP 626 requires that the `continue` is traced, and continue can occur once per iteration. So inserting a NOP for a continue will have a measurable impact on performance.

In some cases the NOP can be folded into the preceding or following bytecode, but often it cannot because the code is both branchy and spread across several lines.

If PEP 626 allowed zero-width entries in the line number table, then any remaining NOPs could be eliminated in the assembler, at the cost of a little additional complexity in `maybe_call_line_trace()`
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86884
2020-12-22 14:00:23Mark.Shannonsetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2020-12-22 12:02:51Mark.Shannoncreate