diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py index f168d169a32948..c0bb805f69ceba 100644 --- a/Lib/_opcode_metadata.py +++ b/Lib/_opcode_metadata.py @@ -2,11 +2,11 @@ # from: # Python/bytecodes.c # Do not edit! -_specializations = { - "RESUME": [ +_specializations = frozendict( + RESUME= [ "RESUME_CHECK", ], - "TO_BOOL": [ + TO_BOOL= [ "TO_BOOL_ALWAYS_TRUE", "TO_BOOL_BOOL", "TO_BOOL_INT", @@ -14,7 +14,7 @@ "TO_BOOL_NONE", "TO_BOOL_STR", ], - "BINARY_OP": [ + BINARY_OP= [ "BINARY_OP_MULTIPLY_INT", "BINARY_OP_ADD_INT", "BINARY_OP_SUBTRACT_INT", @@ -31,32 +31,32 @@ "BINARY_OP_EXTEND", "BINARY_OP_INPLACE_ADD_UNICODE", ], - "STORE_SUBSCR": [ + STORE_SUBSCR= [ "STORE_SUBSCR_DICT", "STORE_SUBSCR_LIST_INT", ], - "SEND": [ + SEND= [ "SEND_GEN", ], - "UNPACK_SEQUENCE": [ + UNPACK_SEQUENCE= [ "UNPACK_SEQUENCE_TWO_TUPLE", "UNPACK_SEQUENCE_TUPLE", "UNPACK_SEQUENCE_LIST", ], - "STORE_ATTR": [ + STORE_ATTR= [ "STORE_ATTR_INSTANCE_VALUE", "STORE_ATTR_SLOT", "STORE_ATTR_WITH_HINT", ], - "LOAD_GLOBAL": [ + LOAD_GLOBAL= [ "LOAD_GLOBAL_MODULE", "LOAD_GLOBAL_BUILTIN", ], - "LOAD_SUPER_ATTR": [ + LOAD_SUPER_ATTR= [ "LOAD_SUPER_ATTR_ATTR", "LOAD_SUPER_ATTR_METHOD", ], - "LOAD_ATTR": [ + LOAD_ATTR= [ "LOAD_ATTR_INSTANCE_VALUE", "LOAD_ATTR_MODULE", "LOAD_ATTR_WITH_HINT", @@ -71,26 +71,26 @@ "LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES", "LOAD_ATTR_NONDESCRIPTOR_NO_DICT", ], - "COMPARE_OP": [ + COMPARE_OP= [ "COMPARE_OP_FLOAT", "COMPARE_OP_INT", "COMPARE_OP_STR", ], - "CONTAINS_OP": [ + CONTAINS_OP= [ "CONTAINS_OP_SET", "CONTAINS_OP_DICT", ], - "JUMP_BACKWARD": [ + JUMP_BACKWARD= [ "JUMP_BACKWARD_NO_JIT", "JUMP_BACKWARD_JIT", ], - "FOR_ITER": [ + FOR_ITER= [ "FOR_ITER_LIST", "FOR_ITER_TUPLE", "FOR_ITER_RANGE", "FOR_ITER_GEN", ], - "CALL": [ + CALL= [ "CALL_BOUND_METHOD_EXACT_ARGS", "CALL_PY_EXACT_ARGS", "CALL_TYPE_1", @@ -112,254 +112,254 @@ "CALL_BOUND_METHOD_GENERAL", "CALL_NON_PY_GENERAL", ], - "CALL_KW": [ + CALL_KW= [ "CALL_KW_BOUND_METHOD", "CALL_KW_PY", "CALL_KW_NON_PY", ], -} +) -_specialized_opmap = { - 'BINARY_OP_ADD_FLOAT': 129, - 'BINARY_OP_ADD_INT': 130, - 'BINARY_OP_ADD_UNICODE': 131, - 'BINARY_OP_EXTEND': 132, - 'BINARY_OP_INPLACE_ADD_UNICODE': 3, - 'BINARY_OP_MULTIPLY_FLOAT': 133, - 'BINARY_OP_MULTIPLY_INT': 134, - 'BINARY_OP_SUBSCR_DICT': 135, - 'BINARY_OP_SUBSCR_GETITEM': 136, - 'BINARY_OP_SUBSCR_LIST_INT': 137, - 'BINARY_OP_SUBSCR_LIST_SLICE': 138, - 'BINARY_OP_SUBSCR_STR_INT': 139, - 'BINARY_OP_SUBSCR_TUPLE_INT': 140, - 'BINARY_OP_SUBTRACT_FLOAT': 141, - 'BINARY_OP_SUBTRACT_INT': 142, - 'CALL_ALLOC_AND_ENTER_INIT': 143, - 'CALL_BOUND_METHOD_EXACT_ARGS': 144, - 'CALL_BOUND_METHOD_GENERAL': 145, - 'CALL_BUILTIN_CLASS': 146, - 'CALL_BUILTIN_FAST': 147, - 'CALL_BUILTIN_FAST_WITH_KEYWORDS': 148, - 'CALL_BUILTIN_O': 149, - 'CALL_ISINSTANCE': 150, - 'CALL_KW_BOUND_METHOD': 151, - 'CALL_KW_NON_PY': 152, - 'CALL_KW_PY': 153, - 'CALL_LEN': 154, - 'CALL_LIST_APPEND': 155, - 'CALL_METHOD_DESCRIPTOR_FAST': 156, - 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 157, - 'CALL_METHOD_DESCRIPTOR_NOARGS': 158, - 'CALL_METHOD_DESCRIPTOR_O': 159, - 'CALL_NON_PY_GENERAL': 160, - 'CALL_PY_EXACT_ARGS': 161, - 'CALL_PY_GENERAL': 162, - 'CALL_STR_1': 163, - 'CALL_TUPLE_1': 164, - 'CALL_TYPE_1': 165, - 'COMPARE_OP_FLOAT': 166, - 'COMPARE_OP_INT': 167, - 'COMPARE_OP_STR': 168, - 'CONTAINS_OP_DICT': 169, - 'CONTAINS_OP_SET': 170, - 'FOR_ITER_GEN': 171, - 'FOR_ITER_LIST': 172, - 'FOR_ITER_RANGE': 173, - 'FOR_ITER_TUPLE': 174, - 'JUMP_BACKWARD_JIT': 175, - 'JUMP_BACKWARD_NO_JIT': 176, - 'LOAD_ATTR_CLASS': 177, - 'LOAD_ATTR_CLASS_WITH_METACLASS_CHECK': 178, - 'LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN': 179, - 'LOAD_ATTR_INSTANCE_VALUE': 180, - 'LOAD_ATTR_METHOD_LAZY_DICT': 181, - 'LOAD_ATTR_METHOD_NO_DICT': 182, - 'LOAD_ATTR_METHOD_WITH_VALUES': 183, - 'LOAD_ATTR_MODULE': 184, - 'LOAD_ATTR_NONDESCRIPTOR_NO_DICT': 185, - 'LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES': 186, - 'LOAD_ATTR_PROPERTY': 187, - 'LOAD_ATTR_SLOT': 188, - 'LOAD_ATTR_WITH_HINT': 189, - 'LOAD_GLOBAL_BUILTIN': 190, - 'LOAD_GLOBAL_MODULE': 191, - 'LOAD_SUPER_ATTR_ATTR': 192, - 'LOAD_SUPER_ATTR_METHOD': 193, - 'RESUME_CHECK': 194, - 'SEND_GEN': 195, - 'STORE_ATTR_INSTANCE_VALUE': 196, - 'STORE_ATTR_SLOT': 197, - 'STORE_ATTR_WITH_HINT': 198, - 'STORE_SUBSCR_DICT': 199, - 'STORE_SUBSCR_LIST_INT': 200, - 'TO_BOOL_ALWAYS_TRUE': 201, - 'TO_BOOL_BOOL': 202, - 'TO_BOOL_INT': 203, - 'TO_BOOL_LIST': 204, - 'TO_BOOL_NONE': 205, - 'TO_BOOL_STR': 206, - 'UNPACK_SEQUENCE_LIST': 207, - 'UNPACK_SEQUENCE_TUPLE': 208, - 'UNPACK_SEQUENCE_TWO_TUPLE': 209, -} +_specialized_opmap = frozendict( + BINARY_OP_ADD_FLOAT= 129, + BINARY_OP_ADD_INT= 130, + BINARY_OP_ADD_UNICODE= 131, + BINARY_OP_EXTEND= 132, + BINARY_OP_INPLACE_ADD_UNICODE= 3, + BINARY_OP_MULTIPLY_FLOAT= 133, + BINARY_OP_MULTIPLY_INT= 134, + BINARY_OP_SUBSCR_DICT= 135, + BINARY_OP_SUBSCR_GETITEM= 136, + BINARY_OP_SUBSCR_LIST_INT= 137, + BINARY_OP_SUBSCR_LIST_SLICE= 138, + BINARY_OP_SUBSCR_STR_INT= 139, + BINARY_OP_SUBSCR_TUPLE_INT= 140, + BINARY_OP_SUBTRACT_FLOAT= 141, + BINARY_OP_SUBTRACT_INT= 142, + CALL_ALLOC_AND_ENTER_INIT= 143, + CALL_BOUND_METHOD_EXACT_ARGS= 144, + CALL_BOUND_METHOD_GENERAL= 145, + CALL_BUILTIN_CLASS= 146, + CALL_BUILTIN_FAST= 147, + CALL_BUILTIN_FAST_WITH_KEYWORDS= 148, + CALL_BUILTIN_O= 149, + CALL_ISINSTANCE= 150, + CALL_KW_BOUND_METHOD= 151, + CALL_KW_NON_PY= 152, + CALL_KW_PY= 153, + CALL_LEN= 154, + CALL_LIST_APPEND= 155, + CALL_METHOD_DESCRIPTOR_FAST= 156, + CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS= 157, + CALL_METHOD_DESCRIPTOR_NOARGS= 158, + CALL_METHOD_DESCRIPTOR_O= 159, + CALL_NON_PY_GENERAL= 160, + CALL_PY_EXACT_ARGS= 161, + CALL_PY_GENERAL= 162, + CALL_STR_1= 163, + CALL_TUPLE_1= 164, + CALL_TYPE_1= 165, + COMPARE_OP_FLOAT= 166, + COMPARE_OP_INT= 167, + COMPARE_OP_STR= 168, + CONTAINS_OP_DICT= 169, + CONTAINS_OP_SET= 170, + FOR_ITER_GEN= 171, + FOR_ITER_LIST= 172, + FOR_ITER_RANGE= 173, + FOR_ITER_TUPLE= 174, + JUMP_BACKWARD_JIT= 175, + JUMP_BACKWARD_NO_JIT= 176, + LOAD_ATTR_CLASS= 177, + LOAD_ATTR_CLASS_WITH_METACLASS_CHECK= 178, + LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN= 179, + LOAD_ATTR_INSTANCE_VALUE= 180, + LOAD_ATTR_METHOD_LAZY_DICT= 181, + LOAD_ATTR_METHOD_NO_DICT= 182, + LOAD_ATTR_METHOD_WITH_VALUES= 183, + LOAD_ATTR_MODULE= 184, + LOAD_ATTR_NONDESCRIPTOR_NO_DICT= 185, + LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES= 186, + LOAD_ATTR_PROPERTY= 187, + LOAD_ATTR_SLOT= 188, + LOAD_ATTR_WITH_HINT= 189, + LOAD_GLOBAL_BUILTIN= 190, + LOAD_GLOBAL_MODULE= 191, + LOAD_SUPER_ATTR_ATTR= 192, + LOAD_SUPER_ATTR_METHOD= 193, + RESUME_CHECK= 194, + SEND_GEN= 195, + STORE_ATTR_INSTANCE_VALUE= 196, + STORE_ATTR_SLOT= 197, + STORE_ATTR_WITH_HINT= 198, + STORE_SUBSCR_DICT= 199, + STORE_SUBSCR_LIST_INT= 200, + TO_BOOL_ALWAYS_TRUE= 201, + TO_BOOL_BOOL= 202, + TO_BOOL_INT= 203, + TO_BOOL_LIST= 204, + TO_BOOL_NONE= 205, + TO_BOOL_STR= 206, + UNPACK_SEQUENCE_LIST= 207, + UNPACK_SEQUENCE_TUPLE= 208, + UNPACK_SEQUENCE_TWO_TUPLE= 209, +) -opmap = { - 'CACHE': 0, - 'RESERVED': 17, - 'RESUME': 128, - 'INSTRUMENTED_LINE': 254, - 'ENTER_EXECUTOR': 255, - 'BINARY_SLICE': 1, - 'BUILD_TEMPLATE': 2, - 'CALL_FUNCTION_EX': 4, - 'CHECK_EG_MATCH': 5, - 'CHECK_EXC_MATCH': 6, - 'CLEANUP_THROW': 7, - 'DELETE_SUBSCR': 8, - 'END_FOR': 9, - 'END_SEND': 10, - 'EXIT_INIT_CHECK': 11, - 'FORMAT_SIMPLE': 12, - 'FORMAT_WITH_SPEC': 13, - 'GET_AITER': 14, - 'GET_ANEXT': 15, - 'GET_ITER': 16, - 'GET_LEN': 18, - 'GET_YIELD_FROM_ITER': 19, - 'INTERPRETER_EXIT': 20, - 'LOAD_BUILD_CLASS': 21, - 'LOAD_LOCALS': 22, - 'MAKE_FUNCTION': 23, - 'MATCH_KEYS': 24, - 'MATCH_MAPPING': 25, - 'MATCH_SEQUENCE': 26, - 'NOP': 27, - 'NOT_TAKEN': 28, - 'POP_EXCEPT': 29, - 'POP_ITER': 30, - 'POP_TOP': 31, - 'PUSH_EXC_INFO': 32, - 'PUSH_NULL': 33, - 'RETURN_GENERATOR': 34, - 'RETURN_VALUE': 35, - 'SETUP_ANNOTATIONS': 36, - 'STORE_SLICE': 37, - 'STORE_SUBSCR': 38, - 'TO_BOOL': 39, - 'UNARY_INVERT': 40, - 'UNARY_NEGATIVE': 41, - 'UNARY_NOT': 42, - 'WITH_EXCEPT_START': 43, - 'BINARY_OP': 44, - 'BUILD_INTERPOLATION': 45, - 'BUILD_LIST': 46, - 'BUILD_MAP': 47, - 'BUILD_SET': 48, - 'BUILD_SLICE': 49, - 'BUILD_STRING': 50, - 'BUILD_TUPLE': 51, - 'CALL': 52, - 'CALL_INTRINSIC_1': 53, - 'CALL_INTRINSIC_2': 54, - 'CALL_KW': 55, - 'COMPARE_OP': 56, - 'CONTAINS_OP': 57, - 'CONVERT_VALUE': 58, - 'COPY': 59, - 'COPY_FREE_VARS': 60, - 'DELETE_ATTR': 61, - 'DELETE_DEREF': 62, - 'DELETE_FAST': 63, - 'DELETE_GLOBAL': 64, - 'DELETE_NAME': 65, - 'DICT_MERGE': 66, - 'DICT_UPDATE': 67, - 'END_ASYNC_FOR': 68, - 'EXTENDED_ARG': 69, - 'FOR_ITER': 70, - 'GET_AWAITABLE': 71, - 'IMPORT_FROM': 72, - 'IMPORT_NAME': 73, - 'IS_OP': 74, - 'JUMP_BACKWARD': 75, - 'JUMP_BACKWARD_NO_INTERRUPT': 76, - 'JUMP_FORWARD': 77, - 'LIST_APPEND': 78, - 'LIST_EXTEND': 79, - 'LOAD_ATTR': 80, - 'LOAD_COMMON_CONSTANT': 81, - 'LOAD_CONST': 82, - 'LOAD_DEREF': 83, - 'LOAD_FAST': 84, - 'LOAD_FAST_AND_CLEAR': 85, - 'LOAD_FAST_BORROW': 86, - 'LOAD_FAST_BORROW_LOAD_FAST_BORROW': 87, - 'LOAD_FAST_CHECK': 88, - 'LOAD_FAST_LOAD_FAST': 89, - 'LOAD_FROM_DICT_OR_DEREF': 90, - 'LOAD_FROM_DICT_OR_GLOBALS': 91, - 'LOAD_GLOBAL': 92, - 'LOAD_NAME': 93, - 'LOAD_SMALL_INT': 94, - 'LOAD_SPECIAL': 95, - 'LOAD_SUPER_ATTR': 96, - 'MAKE_CELL': 97, - 'MAP_ADD': 98, - 'MATCH_CLASS': 99, - 'POP_JUMP_IF_FALSE': 100, - 'POP_JUMP_IF_NONE': 101, - 'POP_JUMP_IF_NOT_NONE': 102, - 'POP_JUMP_IF_TRUE': 103, - 'RAISE_VARARGS': 104, - 'RERAISE': 105, - 'SEND': 106, - 'SET_ADD': 107, - 'SET_FUNCTION_ATTRIBUTE': 108, - 'SET_UPDATE': 109, - 'STORE_ATTR': 110, - 'STORE_DEREF': 111, - 'STORE_FAST': 112, - 'STORE_FAST_LOAD_FAST': 113, - 'STORE_FAST_STORE_FAST': 114, - 'STORE_GLOBAL': 115, - 'STORE_NAME': 116, - 'SWAP': 117, - 'UNPACK_EX': 118, - 'UNPACK_SEQUENCE': 119, - 'YIELD_VALUE': 120, - 'INSTRUMENTED_END_FOR': 234, - 'INSTRUMENTED_POP_ITER': 235, - 'INSTRUMENTED_END_SEND': 236, - 'INSTRUMENTED_FOR_ITER': 237, - 'INSTRUMENTED_INSTRUCTION': 238, - 'INSTRUMENTED_JUMP_FORWARD': 239, - 'INSTRUMENTED_NOT_TAKEN': 240, - 'INSTRUMENTED_POP_JUMP_IF_TRUE': 241, - 'INSTRUMENTED_POP_JUMP_IF_FALSE': 242, - 'INSTRUMENTED_POP_JUMP_IF_NONE': 243, - 'INSTRUMENTED_POP_JUMP_IF_NOT_NONE': 244, - 'INSTRUMENTED_RESUME': 245, - 'INSTRUMENTED_RETURN_VALUE': 246, - 'INSTRUMENTED_YIELD_VALUE': 247, - 'INSTRUMENTED_END_ASYNC_FOR': 248, - 'INSTRUMENTED_LOAD_SUPER_ATTR': 249, - 'INSTRUMENTED_CALL': 250, - 'INSTRUMENTED_CALL_KW': 251, - 'INSTRUMENTED_CALL_FUNCTION_EX': 252, - 'INSTRUMENTED_JUMP_BACKWARD': 253, - 'ANNOTATIONS_PLACEHOLDER': 256, - 'JUMP': 257, - 'JUMP_IF_FALSE': 258, - 'JUMP_IF_TRUE': 259, - 'JUMP_NO_INTERRUPT': 260, - 'LOAD_CLOSURE': 261, - 'POP_BLOCK': 262, - 'SETUP_CLEANUP': 263, - 'SETUP_FINALLY': 264, - 'SETUP_WITH': 265, - 'STORE_FAST_MAYBE_NULL': 266, -} +opmap = frozendict( + CACHE= 0, + RESERVED= 17, + RESUME= 128, + INSTRUMENTED_LINE= 254, + ENTER_EXECUTOR= 255, + BINARY_SLICE= 1, + BUILD_TEMPLATE= 2, + CALL_FUNCTION_EX= 4, + CHECK_EG_MATCH= 5, + CHECK_EXC_MATCH= 6, + CLEANUP_THROW= 7, + DELETE_SUBSCR= 8, + END_FOR= 9, + END_SEND= 10, + EXIT_INIT_CHECK= 11, + FORMAT_SIMPLE= 12, + FORMAT_WITH_SPEC= 13, + GET_AITER= 14, + GET_ANEXT= 15, + GET_ITER= 16, + GET_LEN= 18, + GET_YIELD_FROM_ITER= 19, + INTERPRETER_EXIT= 20, + LOAD_BUILD_CLASS= 21, + LOAD_LOCALS= 22, + MAKE_FUNCTION= 23, + MATCH_KEYS= 24, + MATCH_MAPPING= 25, + MATCH_SEQUENCE= 26, + NOP= 27, + NOT_TAKEN= 28, + POP_EXCEPT= 29, + POP_ITER= 30, + POP_TOP= 31, + PUSH_EXC_INFO= 32, + PUSH_NULL= 33, + RETURN_GENERATOR= 34, + RETURN_VALUE= 35, + SETUP_ANNOTATIONS= 36, + STORE_SLICE= 37, + STORE_SUBSCR= 38, + TO_BOOL= 39, + UNARY_INVERT= 40, + UNARY_NEGATIVE= 41, + UNARY_NOT= 42, + WITH_EXCEPT_START= 43, + BINARY_OP= 44, + BUILD_INTERPOLATION= 45, + BUILD_LIST= 46, + BUILD_MAP= 47, + BUILD_SET= 48, + BUILD_SLICE= 49, + BUILD_STRING= 50, + BUILD_TUPLE= 51, + CALL= 52, + CALL_INTRINSIC_1= 53, + CALL_INTRINSIC_2= 54, + CALL_KW= 55, + COMPARE_OP= 56, + CONTAINS_OP= 57, + CONVERT_VALUE= 58, + COPY= 59, + COPY_FREE_VARS= 60, + DELETE_ATTR= 61, + DELETE_DEREF= 62, + DELETE_FAST= 63, + DELETE_GLOBAL= 64, + DELETE_NAME= 65, + DICT_MERGE= 66, + DICT_UPDATE= 67, + END_ASYNC_FOR= 68, + EXTENDED_ARG= 69, + FOR_ITER= 70, + GET_AWAITABLE= 71, + IMPORT_FROM= 72, + IMPORT_NAME= 73, + IS_OP= 74, + JUMP_BACKWARD= 75, + JUMP_BACKWARD_NO_INTERRUPT= 76, + JUMP_FORWARD= 77, + LIST_APPEND= 78, + LIST_EXTEND= 79, + LOAD_ATTR= 80, + LOAD_COMMON_CONSTANT= 81, + LOAD_CONST= 82, + LOAD_DEREF= 83, + LOAD_FAST= 84, + LOAD_FAST_AND_CLEAR= 85, + LOAD_FAST_BORROW= 86, + LOAD_FAST_BORROW_LOAD_FAST_BORROW= 87, + LOAD_FAST_CHECK= 88, + LOAD_FAST_LOAD_FAST= 89, + LOAD_FROM_DICT_OR_DEREF= 90, + LOAD_FROM_DICT_OR_GLOBALS= 91, + LOAD_GLOBAL= 92, + LOAD_NAME= 93, + LOAD_SMALL_INT= 94, + LOAD_SPECIAL= 95, + LOAD_SUPER_ATTR= 96, + MAKE_CELL= 97, + MAP_ADD= 98, + MATCH_CLASS= 99, + POP_JUMP_IF_FALSE= 100, + POP_JUMP_IF_NONE= 101, + POP_JUMP_IF_NOT_NONE= 102, + POP_JUMP_IF_TRUE= 103, + RAISE_VARARGS= 104, + RERAISE= 105, + SEND= 106, + SET_ADD= 107, + SET_FUNCTION_ATTRIBUTE= 108, + SET_UPDATE= 109, + STORE_ATTR= 110, + STORE_DEREF= 111, + STORE_FAST= 112, + STORE_FAST_LOAD_FAST= 113, + STORE_FAST_STORE_FAST= 114, + STORE_GLOBAL= 115, + STORE_NAME= 116, + SWAP= 117, + UNPACK_EX= 118, + UNPACK_SEQUENCE= 119, + YIELD_VALUE= 120, + INSTRUMENTED_END_FOR= 234, + INSTRUMENTED_POP_ITER= 235, + INSTRUMENTED_END_SEND= 236, + INSTRUMENTED_FOR_ITER= 237, + INSTRUMENTED_INSTRUCTION= 238, + INSTRUMENTED_JUMP_FORWARD= 239, + INSTRUMENTED_NOT_TAKEN= 240, + INSTRUMENTED_POP_JUMP_IF_TRUE= 241, + INSTRUMENTED_POP_JUMP_IF_FALSE= 242, + INSTRUMENTED_POP_JUMP_IF_NONE= 243, + INSTRUMENTED_POP_JUMP_IF_NOT_NONE= 244, + INSTRUMENTED_RESUME= 245, + INSTRUMENTED_RETURN_VALUE= 246, + INSTRUMENTED_YIELD_VALUE= 247, + INSTRUMENTED_END_ASYNC_FOR= 248, + INSTRUMENTED_LOAD_SUPER_ATTR= 249, + INSTRUMENTED_CALL= 250, + INSTRUMENTED_CALL_KW= 251, + INSTRUMENTED_CALL_FUNCTION_EX= 252, + INSTRUMENTED_JUMP_BACKWARD= 253, + ANNOTATIONS_PLACEHOLDER= 256, + JUMP= 257, + JUMP_IF_FALSE= 258, + JUMP_IF_TRUE= 259, + JUMP_NO_INTERRUPT= 260, + LOAD_CLOSURE= 261, + POP_BLOCK= 262, + SETUP_CLEANUP= 263, + SETUP_FINALLY= 264, + SETUP_WITH= 265, + STORE_FAST_MAYBE_NULL= 266, +) HAVE_ARGUMENT = 43 MIN_INSTRUMENTED_OPCODE = 234 diff --git a/Lib/_pydatetime.py b/Lib/_pydatetime.py index b6d68f2372850a..1a93279286d080 100644 --- a/Lib/_pydatetime.py +++ b/Lib/_pydatetime.py @@ -164,13 +164,13 @@ def _build_struct_time(y, m, d, hh, mm, ss, dstflag): return _time.struct_time((y, m, d, hh, mm, ss, wday, dnum, dstflag)) def _format_time(hh, mm, ss, us, timespec='auto'): - specs = { - 'hours': '{:02d}', - 'minutes': '{:02d}:{:02d}', - 'seconds': '{:02d}:{:02d}:{:02d}', - 'milliseconds': '{:02d}:{:02d}:{:02d}.{:03d}', - 'microseconds': '{:02d}:{:02d}:{:02d}.{:06d}' - } + specs = frozendict( + hours= '{:02d}', + minutes= '{:02d}:{:02d}', + seconds= '{:02d}:{:02d}:{:02d}', + milliseconds= '{:02d}:{:02d}:{:02d}.{:03d}', + microseconds= '{:02d}:{:02d}:{:02d}.{:06d}' + ) if timespec == 'auto': # Skip trailing microseconds when us==0. diff --git a/Lib/bdb.py b/Lib/bdb.py index efc3e0a235ac8e..2f406f1fced4b5 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -20,7 +20,7 @@ class BdbQuit(Exception): E = sys.monitoring.events class _MonitoringTracer: - EVENT_CALLBACK_MAP = { + EVENT_CALLBACK_MAP = frozendict({ E.PY_START: 'call', E.PY_RESUME: 'call', E.PY_THROW: 'call', @@ -32,7 +32,7 @@ class _MonitoringTracer: E.RAISE: 'exception', E.STOP_ITERATION: 'exception', E.INSTRUCTION: 'opcode', - } + }) GLOBAL_EVENTS = E.PY_START | E.PY_RESUME | E.PY_THROW | E.PY_UNWIND | E.RAISE LOCAL_EVENTS = E.LINE | E.JUMP | E.PY_RETURN | E.PY_YIELD | E.STOP_ITERATION diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py index bc446e0f377a11..3268388c0be042 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -30,6 +30,9 @@ for i in range(0x20): ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i)) #ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,)) + +# freeze the dict to prevent accidental modifications +ESCAPE_DCT = frozendict(ESCAPE_DCT) del i INFINITY = float('inf') diff --git a/Lib/opcode.py b/Lib/opcode.py index 0e9520b6832499..ef183475972053 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -45,78 +45,78 @@ hascompare = [opmap["COMPARE_OP"]] -_cache_format = { - "LOAD_GLOBAL": { +_cache_format = frozendict( + LOAD_GLOBAL= { "counter": 1, "index": 1, "module_keys_version": 1, "builtin_keys_version": 1, }, - "BINARY_OP": { + BINARY_OP= { "counter": 1, "descr": 4, }, - "UNPACK_SEQUENCE": { + UNPACK_SEQUENCE= { "counter": 1, }, - "COMPARE_OP": { + COMPARE_OP= { "counter": 1, }, - "CONTAINS_OP": { + CONTAINS_OP= { "counter": 1, }, - "FOR_ITER": { + FOR_ITER= { "counter": 1, }, - "LOAD_SUPER_ATTR": { + LOAD_SUPER_ATTR= { "counter": 1, }, - "LOAD_ATTR": { + LOAD_ATTR= { "counter": 1, "version": 2, "keys_version": 2, "descr": 4, }, - "STORE_ATTR": { + STORE_ATTR= { "counter": 1, "version": 2, "index": 1, }, - "CALL": { + CALL= { "counter": 1, "func_version": 2, }, - "CALL_KW": { + CALL_KW= { "counter": 1, "func_version": 2, }, - "STORE_SUBSCR": { + STORE_SUBSCR= { "counter": 1, }, - "SEND": { + SEND= { "counter": 1, }, - "JUMP_BACKWARD": { + JUMP_BACKWARD= { "counter": 1, }, - "TO_BOOL": { + TO_BOOL= { "counter": 1, "version": 2, }, - "POP_JUMP_IF_TRUE": { + POP_JUMP_IF_TRUE= { "counter": 1, }, - "POP_JUMP_IF_FALSE": { + POP_JUMP_IF_FALSE= { "counter": 1, }, - "POP_JUMP_IF_NONE": { + POP_JUMP_IF_NONE= { "counter": 1, }, - "POP_JUMP_IF_NOT_NONE": { + POP_JUMP_IF_NOT_NONE= { "counter": 1, }, -} +) -_inline_cache_entries = { +_inline_cache_entries = frozendict({ name : sum(value.values()) for (name, value) in _cache_format.items() -} +}) diff --git a/Tools/cases_generator/py_metadata_generator.py b/Tools/cases_generator/py_metadata_generator.py index 3ec06faf338488..73cdc9f3b31350 100644 --- a/Tools/cases_generator/py_metadata_generator.py +++ b/Tools/cases_generator/py_metadata_generator.py @@ -30,17 +30,17 @@ def get_specialized(analysis: Analysis) -> set[str]: def generate_specializations(analysis: Analysis, out: CWriter) -> None: - out.emit("_specializations = {\n") + out.emit("_specializations = frozendict(\n") for family in analysis.families.values(): - out.emit(f'"{family.name}": [\n') + out.emit(f'{family.name}= [\n') for member in family.members: out.emit(f' "{member.name}",\n') out.emit("],\n") - out.emit("}\n\n") + out.emit(")\n\n") def generate_specialized_opmap(analysis: Analysis, out: CWriter) -> None: - out.emit("_specialized_opmap = {\n") + out.emit("_specialized_opmap = frozendict(\n") names = [] for family in analysis.families.values(): for member in family.members: @@ -48,17 +48,17 @@ def generate_specialized_opmap(analysis: Analysis, out: CWriter) -> None: continue names.append(member.name) for name in sorted(names): - out.emit(f"'{name}': {analysis.opmap[name]},\n") - out.emit("}\n\n") + out.emit(f"{name}= {analysis.opmap[name]},\n") + out.emit(")\n\n") def generate_opmap(analysis: Analysis, out: CWriter) -> None: specialized = get_specialized(analysis) - out.emit("opmap = {\n") + out.emit("opmap = frozendict(\n") for inst, op in analysis.opmap.items(): if inst not in specialized: - out.emit(f"'{inst}': {analysis.opmap[inst]},\n") - out.emit("}\n\n") + out.emit(f"{inst}= {analysis.opmap[inst]},\n") + out.emit(")\n\n") def generate_py_metadata(