Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
EXTENDED_ARG = opmap['EXTENDED_ARG']

opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
for op, i in opmap.items():
opname[i] = op
for m in (opmap, _specialized_opmap):
for op, i in m.items():
opname[i] = op

cmp_op = ('<', '<=', '==', '!=', '>', '>=')

Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test__opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def test_is_valid(self):
opcodes = [dis.opmap[opname] for opname in names]
self.check_bool_function_result(_opcode.is_valid, opcodes, True)

def test_opmaps(self):
def check_roundtrip(name, map):
return self.assertEqual(opcode.opname[map[name]], name)

check_roundtrip('BINARY_OP', opcode.opmap)
check_roundtrip('BINARY_OP_ADD_INT', opcode._specialized_opmap)

def test_oplists(self):
def check_function(self, func, expected):
for op in [-10, 520]:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add specialized opcodes to `opcode.opname`.
Loading