op 大全
import disnum=0
for x in range(255):
s=dis.opname
if "<" not in s:
print(s)
num+=1
#print(num)
'''
POP_TOP
ROT_TWO
ROT_THREE
DUP_TOP
DUP_TOP_TWO
NOP
UNARY_POSITIVE
UNARY_NEGATIVE
UNARY_NOT
UNARY_INVERT
BINARY_MATRIX_MULTIPLY
INPLACE_MATRIX_MULTIPLY
BINARY_POWER
BINARY_MULTIPLY
BINARY_MODULO
BINARY_ADD
BINARY_SUBTRACT
BINARY_SUBSCR
BINARY_FLOOR_DIVIDE
BINARY_TRUE_DIVIDE
INPLACE_FLOOR_DIVIDE
INPLACE_TRUE_DIVIDE
GET_AITER
GET_ANEXT
BEFORE_ASYNC_WITH
INPLACE_ADD
INPLACE_SUBTRACT
INPLACE_MULTIPLY
INPLACE_MODULO
STORE_SUBSCR
DELETE_SUBSCR
BINARY_LSHIFT
BINARY_RSHIFT
BINARY_AND
BINARY_XOR
BINARY_OR
INPLACE_POWER
GET_ITER
GET_YIELD_FROM_ITER
PRINT_EXPR
LOAD_BUILD_CLASS
YIELD_FROM
GET_AWAITABLE
INPLACE_LSHIFT
INPLACE_RSHIFT
INPLACE_AND
INPLACE_XOR
INPLACE_OR
BREAK_LOOP
WITH_CLEANUP_START
WITH_CLEANUP_FINISH
RETURN_VALUE
IMPORT_STAR
SETUP_ANNOTATIONS
YIELD_VALUE
POP_BLOCK
END_FINALLY
POP_EXCEPT
STORE_NAME
DELETE_NAME
UNPACK_SEQUENCE
FOR_ITER
UNPACK_EX
STORE_ATTR
DELETE_ATTR
STORE_GLOBAL
DELETE_GLOBAL
LOAD_CONST
LOAD_NAME
BUILD_TUPLE
BUILD_LIST
BUILD_SET
BUILD_MAP
LOAD_ATTR
COMPARE_OP
IMPORT_NAME
IMPORT_FROM
JUMP_FORWARD
JUMP_IF_FALSE_OR_POP
JUMP_IF_TRUE_OR_POP
JUMP_ABSOLUTE
POP_JUMP_IF_FALSE
POP_JUMP_IF_TRUE
LOAD_GLOBAL
CONTINUE_LOOP
SETUP_LOOP
SETUP_EXCEPT
SETUP_FINALLY
LOAD_FAST
STORE_FAST
DELETE_FAST
RAISE_VARARGS
CALL_FUNCTION
MAKE_FUNCTION
BUILD_SLICE
LOAD_CLOSURE
LOAD_DEREF
STORE_DEREF
DELETE_DEREF
CALL_FUNCTION_KW
CALL_FUNCTION_EX
SETUP_WITH
EXTENDED_ARG
LIST_APPEND
SET_ADD
MAP_ADD
LOAD_CLASSDEREF
BUILD_LIST_UNPACK
BUILD_MAP_UNPACK
BUILD_MAP_UNPACK_WITH_CALL
BUILD_TUPLE_UNPACK
BUILD_SET_UNPACK
SETUP_ASYNC_WITH
FORMAT_VALUE
BUILD_CONST_KEY_MAP
BUILD_STRING
BUILD_TUPLE_UNPACK_WITH_CALL
LOAD_METHOD
CALL_METHOD
''' num1="987654123456789"
num2="123456789654321"
num1 = list(num1)[::-1]
num2 = list(num2)[::-1]
result = * (len(num1) + len(num2))
for i in range(len(num1)):
for j in range(len(num2)):
result += int(num1) * int(num2)
result += result // 10
result %= 10
result = ''.join(str(x) for x in result[::-1]).lstrip('0')
print(result)
'''
D:\pige>py -m dis file3.py
1 0 LOAD_CONST 加载常量 0 ('987654123456789')
2 STORE_NAME 将栈顶值存储到变量中 0 (num1)
2 4 LOAD_CONST 1 ('123456789654321')
6 STORE_NAME 1 (num2)
3 8 LOAD_NAME 获取变量值,并压入栈顶 2 (list)
10 LOAD_NAME 0 (num1)
12 CALL_FUNCTION 调用函数 1
14 LOAD_CONST 2 (None)
16 LOAD_CONST 2 (None)
18 LOAD_CONST 3 (-1)
20 BUILD_SLICE 获取切片对象 3
22 BINARY_SUBSCR从序列中取数,并压入栈顶
24 STORE_NAME 0 (num1)
4 26 LOAD_NAME 2 (list)
28 LOAD_NAME 1 (num2)
30 CALL_FUNCTION 1
32 LOAD_CONST 2 (None)
34 LOAD_CONST 2 (None)
36 LOAD_CONST 3 (-1)
38 BUILD_SLICE 3
40 BINARY_SUBSCR
42 STORE_NAME 1 (num2)
5 44 LOAD_CONST 4 (0)
46 BUILD_LIST 1
48 LOAD_NAME 3 (len)
50 LOAD_NAME 0 (num1)
52 CALL_FUNCTION 1
54 LOAD_NAME 3 (len)
56 LOAD_NAME 1 (num2)
58 CALL_FUNCTION 1
60 BINARY_ADD 加法运算
62 BINARY_MULTIPLY乘法运算
64 STORE_NAME 4 (result)
6 66 SETUP_LOOP 设置循环初始标签 并压入栈 138 (to 206)
68 LOAD_NAME 5 (range)
70 LOAD_NAME 3 (len)
72 LOAD_NAME 0 (num1)
74 CALL_FUNCTION 1
76 CALL_FUNCTION 1
78 GET_ITER 获取迭代器
>> 80 FOR_ITER 再循环中迭代这个迭代器 122 (to 204)
82 STORE_NAME 6 (i)
7 84 SETUP_LOOP 116 (to 202)
86 LOAD_NAME 5 (range)
88 LOAD_NAME 3 (len)
90 LOAD_NAME 1 (num2)
92 CALL_FUNCTION 1
94 CALL_FUNCTION 1
96 GET_ITER
>> 98 FOR_ITER 100 (to 200)
100 STORE_NAME 7 (j)
8 102 LOAD_NAME 4 (result)
104 LOAD_NAME 6 (i)
106 LOAD_NAME 7 (j)
108 BINARY_ADD
110 DUP_TOP_TWO 复制栈顶两个元素 并入栈
112 BINARY_SUBSCR
114 LOAD_NAME 8 (int)
116 LOAD_NAME 0 (num1)
118 LOAD_NAME 6 (i)
120 BINARY_SUBSCR
122 CALL_FUNCTION 1
124 LOAD_NAME 8 (int)
126 LOAD_NAME 1 (num2)
128 LOAD_NAME 7 (j)
130 BINARY_SUBSCR
132 CALL_FUNCTION 1
134 BINARY_MULTIPLY
136 INPLACE_ADD 原地加
138 ROT_THREE 栈顶三个元素旋转
140 STORE_SUBSCR
9 142 LOAD_NAME 4 (result)
144 LOAD_NAME 6 (i)
146 LOAD_NAME 7 (j)
148 BINARY_ADD
150 LOAD_CONST 5 (1)
152 BINARY_ADD
154 DUP_TOP_TWO
156 BINARY_SUBSCR
158 LOAD_NAME 4 (result)
160 LOAD_NAME 6 (i)
162 LOAD_NAME 7 (j)
164 BINARY_ADD
166 BINARY_SUBSCR
168 LOAD_CONST 6 (10)
170 BINARY_FLOOR_DIVIDE 地板除
172 INPLACE_ADD
174 ROT_THREE
176 STORE_SUBSCR
10 178 LOAD_NAME 4 (result)
180 LOAD_NAME 6 (i)
182 LOAD_NAME 7 (j)
184 BINARY_ADD
186 DUP_TOP_TWO
188 BINARY_SUBSCR
190 LOAD_CONST 6 (10)
192 INPLACE_MODULO 原地取模
194 ROT_THREE
196 STORE_SUBSCR
198 JUMP_ABSOLUTE 98
>>200 POP_BLOCK 从块堆栈中 取出最上层块
>>202 JUMP_ABSOLUTE 跳转到指定位置 80
>>204 POP_BLOCK
11 >>206 LOAD_CONST 7 ('')
208 LOAD_METHOD 加载方法 9 (join)
210 LOAD_CONST 8 (<code object <genexpr> at 0x0000021064EE2390, file "file3.py", line 11>)
212 LOAD_CONST 9 ('<genexpr>')
214 MAKE_FUNCTION 创建一个函数对象 0
216 LOAD_NAME 4 (result)
218 LOAD_CONST 2 (None)
220 LOAD_CONST 2 (None)
222 LOAD_CONST 3 (-1)
224 BUILD_SLICE 3
226 BINARY_SUBSCR
228 GET_ITER
230 CALL_FUNCTION 1
232 CALL_METHOD 调用方法 1
234 LOAD_METHOD 10 (lstrip)
236 LOAD_CONST 10 ('0')
238 CALL_METHOD 1
240 STORE_NAME 4 (result)
12 242 LOAD_NAME 11 (print)
244 LOAD_NAME 4 (result)
246 CALL_FUNCTION 1
248 POP_TOP
250 LOAD_CONST 2 (None)
252 RETURN_VALUE
Disassembly of <code object <genexpr> at 0x0000021064EE2390, file "file3.py", line 11>:
11 0 LOAD_FAST 0 (.0)
>> 2 FOR_ITER 14 (to 18)
4 STORE_FAST 1 (x)
6 LOAD_GLOBAL 加载本地变量 0 (str)
8 LOAD_FAST 1 (x)
10 CALL_FUNCTION 1
12 YIELD_VALUE 将栈顶值返回给调用者,并暂停函数执行
14 POP_TOP
16 JUMP_ABSOLUTE 2
>> 18 LOAD_CONST 0 (None)
20 RETURN_VALUE 返回函数值
'''
页:
[1]