0
我寫含循環功能 一些程序使用的DIS模塊拆卸蟒蛇字節碼指令研究
import dis
def f():
a = 10
while a < 50:
print a
a+=1
while a < 100:
print a
a+=1
dis.dis(f)
0 load_const 1 (10)
3 store_fast 0 (a)
6 setup_loop 31 (to 40)
9 load_fast 0 (a)
12 load_const 2(50)
15 compare_op 0(<)
18 pop_jump_if_false 39
21 laod_fast 0(a)
24 print_item
25 print_newline
26 load_fast 0(a)
29 load_const 3(1)
32 inplace_add
33store_fast 0(a)
36 jump_absolute 9
39 pop_block
40 setup_loop 31 (to 74)
43 load_fast 0(a)
46 load_const 4(10)
49 compare_op 0 (<)
52 pop_jump_if_false 73
55 load_fast 0(a)
58 print_item
59 print_newline
60 load_fast 0 (a)
63 load_const 3(1)
66 inplace_add
67 store_fast 0(a)
70 jump_absolute 43
73 pop_block
74 load_const 0(none)
77 return_value
,我看到像load_const, load_name等.... 一些指令,但我沒有如何實際SETUP_LOOP和函數調用說明..... 請任何人告訴如何這些實際上在虛擬機上工作... 有沒有任何鏈接可供閱讀?