Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python字节码指令研究_Python_Bytecode - Fatal编程技术网

python字节码指令研究

python字节码指令研究,python,bytecode,Python,Bytecode,我写了一些包含循环函数的程序 使用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_fa

我写了一些包含循环函数的程序 使用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
导入dis
def():
a=10
当a<50时:
打印
a+=1
当a<100时:
打印
a+=1
dis.dis(f)
0负载常数1(10)
3商店快0(a)
6设置回路31(至40)
9加载速度0(a)
12负载常数2(50)

15比较\u op 0(假设您只对CPython如何发挥其魔力感兴趣,请更具体地看
\u PyEval\u evalframefault
函数。所有操作码都在那里