x = 0
Consider the above code snippet. The dis module outputs the line numbers along with the bytecode offsets.
1 0 LOAD_CONST 0 (0)
2 STORE_NAME 0 (x)
4 LOAD_CONST 1 (None)
6 RETURN_VALUE
Using the bytecode module I get the following, except the offset=<> part. Is there any way I can get these offsets, similar to the dis module's output?
<LOAD_CONST arg=0 lineno=1 offset=0>
<STORE_NAME arg='x' lineno=1 offset=2>
<LOAD_CONST arg=None lineno=1 offset=4>
<RETURN_VALUE lineno=1 offset=6>>
I modified the bytecode module source to get the above output. If there is no other way except modifying the source, should I submit a PR?
x = 0Consider the above code snippet. The dis module outputs the line numbers along with the bytecode offsets.
Using the
bytecodemodule I get the following, except theoffset=<>part. Is there any way I can get these offsets, similar to the dis module's output?I modified the bytecode module source to get the above output. If there is no other way except modifying the source, should I submit a PR?