i have the following code
code = '''
x = ['a','b','c']
for each in x:
print(each)
'''
I used python's dis function of dis package and got the following output
dis.dis(code)
> 2 0 LOAD_CONST 0 ('a')
> 2 LOAD_CONST 1 ('b')
> 4 LOAD_CONST 2 ('c')
> 6 BUILD_LIST 3
> 8 STORE_NAME 0 (x)
>
> 3 10 SETUP_LOOP 20 (to 32)
> 12 LOAD_NAME 0 (x)
> 14 GET_ITER
> >> 16 FOR_ITER 12 (to 30)
> 18 STORE_NAME 1 (each)
>
> 4 20 LOAD_NAME 2 (print)
> 22 LOAD_NAME 1 (each)
> 24 CALL_FUNCTION 1
> 26 POP_TOP
> 28 JUMP_ABSOLUTE 16
> >> 30 POP_BLOCK
> >> 32 LOAD_CONST 3 (None)
> 34 RETURN_VALUE
I am wondering what's the significance of >> in this output. its being printed for FOR_ITER, POP_BLOCK, LOAD_CONST.
If you look for the byte offsets you will observe that each of the tagged lines is the object of a jump or other branching operation. It's supposed to help you identify loop scopes and the like more easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With