[New-bugs-announce] [issue42718] Allow zero-width entries in code.co_lines()

Mark Shannon report at bugs.python.org
Tue Dec 22 07:02:51 EST 2020


New submission from Mark Shannon <mark at hotpy.org>:

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:
        continue
    rest

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()`

----------
assignee: Mark.Shannon
components: Interpreter Core
messages: 383585
nosy: Mark.Shannon, pablogsal, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Allow zero-width entries in code.co_lines()
type: performance
versions: Python 3.10

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


More information about the New-bugs-announce mailing list