bpo-45636: Merge all numeric operators (GH-29482)

This commit is contained in:
Brandt Bucher 2021-11-10 22:56:22 -08:00 committed by GitHub
parent 1cbaa505d0
commit 9178f533ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 613 additions and 1081 deletions

View file

@ -7,6 +7,7 @@ import io
from opcode import *
from opcode import __all__ as _opcodes_all
from opcode import _nb_ops
__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels", "show_code",
@ -27,6 +28,7 @@ MAKE_FUNCTION = opmap['MAKE_FUNCTION']
MAKE_FUNCTION_FLAGS = ('defaults', 'kwdefaults', 'annotations', 'closure')
LOAD_CONST = opmap['LOAD_CONST']
BINARY_OP = opmap['BINARY_OP']
def _try_compile(source, name):
"""Attempts to compile the given source, first as an expression and
@ -446,6 +448,8 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
elif op == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
elif op == BINARY_OP:
_, argrepr = _nb_ops[arg]
yield Instruction(opname[op], op,
arg, argval, argrepr,
offset, starts_line, is_jump_target, positions)