Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Feature or enhancement
Proposal:
dis.dis is a useful debugging tool when trying to debug minor bytecode compiler errors.
However it lacks one important feature, the ability to see the exact positions attached to instructions. It can only show line numbers.
We should add ashow_positions keyword argument to show positions.
For example, the function:
deffoo(x):ifx==2:return1
disassembles to:
2 RESUME 0 3 LOAD_FAST 0 (x) LOAD_CONST 1 (2) COMPARE_OP 88 (bool(==)) POP_JUMP_IF_FALSE 1 (to L1) 4 RETURN_CONST 2 (1) 3 L1: RETURN_CONST 0 (None)withshow_positions it would disassemble to something like:
2:0-2:0 RESUME 03:7-3:8 LOAD_FAST 0 (x)3:12-3:13 LOAD_CONST 1 (2)3:7-3:13 COMPARE_OP 88 (bool(==))3:7-3:13 POP_JUMP_IF_FALSE 1 (to L1)4:15-4:16 RETURN_CONST 2 (1)3:7-3:13 L1: RETURN_CONST 0 (None)Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response