From d6ecee159b5de2e2891a03358042b7e20e9be23b Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 15 Aug 2023 14:15:06 +0100 Subject: [PATCH] remove _specialized_instructions, we have the same in _specialized_opmap now --- Lib/_opcode_metadata.py | 2 -- Lib/dis.py | 1 - Lib/opcode.py | 2 +- Lib/test/test_dis.py | 2 +- Lib/test/test_embed.py | 2 +- Tools/cases_generator/generate_cases.py | 8 -------- Tools/scripts/summarize_stats.py | 4 ++-- 7 files changed, 5 insertions(+), 16 deletions(-) diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py index 08a4e47b8f5140..35dae891fc6339 100644 --- a/Lib/_opcode_metadata.py +++ b/Lib/_opcode_metadata.py @@ -103,8 +103,6 @@ # An irregular case: _specializations["BINARY_OP"].append("BINARY_OP_INPLACE_ADD_UNICODE") -_specialized_instructions = [opcode for family in _specializations.values() for opcode in family] - _specialized_opmap = { 'BINARY_OP_ADD_FLOAT': 3, 'BINARY_OP_ADD_INT': 4, diff --git a/Lib/dis.py b/Lib/dis.py index a4ffb33abedab7..4f4e77f32503df 100644 --- a/Lib/dis.py +++ b/Lib/dis.py @@ -14,7 +14,6 @@ _intrinsic_1_descs, _intrinsic_2_descs, _specializations, - _specialized_instructions, _specialized_opmap, ) diff --git a/Lib/opcode.py b/Lib/opcode.py index 4ad335e2fdb62e..6b9d9ce811a61c 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -14,7 +14,7 @@ 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_instructions, _specialized_opmap + from _opcode_metadata import _specializations, _specialized_opmap from _opcode_metadata import opmap, HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE EXTENDED_ARG = opmap['EXTENDED_ARG'] diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 8b192106984350..aa967178c1dc39 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1942,7 +1942,7 @@ def test_baseopname_and_baseopcode(self): self.assertEqual(code, baseopcode) # Specialized instructions - for name in opcode._specialized_instructions: + for name in opcode._specialized_opmap: instruction = Instruction(opname=name, opcode=dis._all_opmap[name], arg=None, argval=None, argrepr='', offset=0, start_offset=0, starts_line=1, is_jump_target=False, positions=None) baseopname = instruction.baseopname diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 582392ecddcb91..50c9f61017e022 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -361,7 +361,7 @@ def is_specialized(f): for instruction in dis.get_instructions(f, adaptive=True): opname = instruction.opname if ( - opname in opcode._specialized_instructions + opname in opcode._specialized_opmap # Exclude superinstructions: and "__" not in opname ): diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 6895b87f1303d1..0ac49b00ef6545 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -550,14 +550,6 @@ def write_metadata(self, metadata_filename: str, pymetadata_filename: str) -> No ) specialized_ops.add("BINARY_OP_INPLACE_ADD_UNICODE") - # Make list of specialized instructions - self.out.emit("") - self.out.emit( - "_specialized_instructions = [" - "opcode for family in _specializations.values() for opcode in family" - "]" - ) - # emit specialized opmap self.out.emit("") with self.out.block("_specialized_opmap ="): diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index f798b2f772d08a..2d198506fb5c6c 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -17,7 +17,7 @@ DEFAULT_DIR = "/tmp/py_stats/" #Create list of all instruction names -specialized = iter(opcode._specialized_instructions) +specialized = iter(opcode._specialized_opmap.keys()) opname = ["<0>"] for name in opcode.opname[1:]: if name.startswith("<"): @@ -244,7 +244,7 @@ def categorized_counts(opcode_stats): specialized = 0 not_specialized = 0 specialized_instructions = { - op for op in opcode._specialized_instructions + op for op in opcode._specialized_opmap.keys() if "__" not in op} for i, opcode_stat in enumerate(opcode_stats): if "execution_count" not in opcode_stat: