diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-08-23 17:39:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-23 17:39:00 (GMT) |
commit | 72119d16a5f658939809febef29dadeca02cf34d (patch) | |
tree | cbcc9877f2a83559ee76c91a18330f1aeae36115 /Lib/opcode.py | |
parent | 422f81b5d2359063826b8561f698d57e94f6a5d8 (diff) | |
download | cpython-72119d16a5f658939809febef29dadeca02cf34d.zip cpython-72119d16a5f658939809febef29dadeca02cf34d.tar.gz cpython-72119d16a5f658939809febef29dadeca02cf34d.tar.bz2 |
gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. (#108367)
Diffstat (limited to 'Lib/opcode.py')
-rw-r--r-- | Lib/opcode.py | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/Lib/opcode.py b/Lib/opcode.py index f848752..386a2fb 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -5,48 +5,40 @@ operate on bytecodes (e.g. peephole optimizers). """ -# Note that __all__ is further extended below -__all__ = ["cmp_op", "stack_effect", "hascompare"] +__all__ = ["cmp_op", "stack_effect", "hascompare", "opname", "opmap", + "HAVE_ARGUMENT", "EXTENDED_ARG", "hasarg", "hasconst", "hasname", + "hasjump", "hasjrel", "hasjabs", "hasfree", "haslocal", "hasexc"] import _opcode from _opcode import stack_effect -import sys -# The build uses older versions of Python which do not have _opcode_metadata -if sys.version_info[:2] >= (3, 13): - from _opcode_metadata import _specializations, _specialized_opmap - from _opcode_metadata import opmap, HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE - EXTENDED_ARG = opmap['EXTENDED_ARG'] +from _opcode_metadata import (_specializations, _specialized_opmap, opmap, + HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) +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 - - __all__.extend(["opname", "opmap", "HAVE_ARGUMENT", "EXTENDED_ARG"]) +opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)] +for op, i in opmap.items(): + opname[i] = op cmp_op = ('<', '<=', '==', '!=', '>', '>=') -# The build uses older versions of Python which do not have _opcode.has_* functions -if sys.version_info[:2] >= (3, 13): - # These lists are documented as part of the dis module's API - hasarg = [op for op in opmap.values() if _opcode.has_arg(op)] - hasconst = [op for op in opmap.values() if _opcode.has_const(op)] - hasname = [op for op in opmap.values() if _opcode.has_name(op)] - hasjump = [op for op in opmap.values() if _opcode.has_jump(op)] - hasjrel = hasjump # for backward compatibility - hasjabs = [] - hasfree = [op for op in opmap.values() if _opcode.has_free(op)] - haslocal = [op for op in opmap.values() if _opcode.has_local(op)] - hasexc = [op for op in opmap.values() if _opcode.has_exc(op)] +# These lists are documented as part of the dis module's API +hasarg = [op for op in opmap.values() if _opcode.has_arg(op)] +hasconst = [op for op in opmap.values() if _opcode.has_const(op)] +hasname = [op for op in opmap.values() if _opcode.has_name(op)] +hasjump = [op for op in opmap.values() if _opcode.has_jump(op)] +hasjrel = hasjump # for backward compatibility +hasjabs = [] +hasfree = [op for op in opmap.values() if _opcode.has_free(op)] +haslocal = [op for op in opmap.values() if _opcode.has_local(op)] +hasexc = [op for op in opmap.values() if _opcode.has_exc(op)] - __all__.extend(["hasarg", "hasconst", "hasname", "hasjump", "hasjrel", - "hasjabs", "hasfree", "haslocal", "hasexc"]) - _intrinsic_1_descs = _opcode.get_intrinsic1_descs() - _intrinsic_2_descs = _opcode.get_intrinsic2_descs() - _nb_ops = _opcode.get_nb_ops() +_intrinsic_1_descs = _opcode.get_intrinsic1_descs() +_intrinsic_2_descs = _opcode.get_intrinsic2_descs() +_nb_ops = _opcode.get_nb_ops() - hascompare = [opmap["COMPARE_OP"]] +hascompare = [opmap["COMPARE_OP"]] _cache_format = { "LOAD_GLOBAL": { |