From 43112e0b9f20ca48a96dce41c79c957efd8cfcd2 Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sun, 6 Mar 2022 21:48:22 +0800 Subject: [PATCH 01/13] Specialize calls to Python classes --- Include/cpython/object.h | 1 + Include/internal/pycore_frame.h | 2 + Include/opcode.h | 29 +++++++------- Lib/opcode.py | 1 + Python/ceval.c | 67 +++++++++++++++++++++++++++++++++ Python/opcode_targets.h | 14 +++---- Python/specialize.c | 47 ++++++++++++++++++----- 7 files changed, 130 insertions(+), 31 deletions(-) diff --git a/Include/cpython/object.h b/Include/cpython/object.h index b018dabf9d862f..11e001b1b467a1 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -234,6 +234,7 @@ struct _typeobject { * by code other than the specializer and interpreter. */ struct _specialization_cache { PyObject *getitem; + PyObject *init; }; /* The *real* layout of a type object when allocated on the heap */ diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index 207983dcc22d7c..d4d3a1b7538b6f 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -61,6 +61,7 @@ typedef struct _PyInterpreterFrame { PyFrameState f_state; /* What state the frame is in */ bool is_entry; // Whether this is the "root" frame for the current _PyCFrame. bool is_generator; + PyObject *self; /* Strong reference consumed by __init__ frames to return self in RETURN_VALUE */ PyObject *localsplus[1]; } _PyInterpreterFrame; @@ -118,6 +119,7 @@ _PyFrame_InitializeSpecials( frame->f_state = FRAME_CREATED; frame->is_entry = false; frame->is_generator = false; + frame->self = NULL; } /* Gets the pointer to the locals array diff --git a/Include/opcode.h b/Include/opcode.h index 1b9eeacdeab013..91cd36888869b9 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -169,20 +169,21 @@ extern "C" { #define PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST 81 #define PRECALL_BOUND_METHOD 140 #define PRECALL_PYFUNC 141 -#define RESUME_QUICK 143 -#define STORE_ATTR_ADAPTIVE 150 -#define STORE_ATTR_INSTANCE_VALUE 153 -#define STORE_ATTR_SLOT 154 -#define STORE_ATTR_WITH_HINT 158 -#define UNPACK_SEQUENCE_ADAPTIVE 159 -#define UNPACK_SEQUENCE_LIST 161 -#define UNPACK_SEQUENCE_TUPLE 167 -#define UNPACK_SEQUENCE_TWO_TUPLE 168 -#define LOAD_FAST__LOAD_FAST 169 -#define STORE_FAST__LOAD_FAST 170 -#define LOAD_FAST__LOAD_CONST 173 -#define LOAD_CONST__LOAD_FAST 174 -#define STORE_FAST__STORE_FAST 175 +#define PRECALL_PY_CLASS 143 +#define RESUME_QUICK 150 +#define STORE_ATTR_ADAPTIVE 153 +#define STORE_ATTR_INSTANCE_VALUE 154 +#define STORE_ATTR_SLOT 158 +#define STORE_ATTR_WITH_HINT 159 +#define UNPACK_SEQUENCE_ADAPTIVE 161 +#define UNPACK_SEQUENCE_LIST 167 +#define UNPACK_SEQUENCE_TUPLE 168 +#define UNPACK_SEQUENCE_TWO_TUPLE 169 +#define LOAD_FAST__LOAD_FAST 170 +#define STORE_FAST__LOAD_FAST 173 +#define LOAD_FAST__LOAD_CONST 174 +#define LOAD_CONST__LOAD_FAST 175 +#define STORE_FAST__STORE_FAST 176 #define DO_TRACING 255 extern const uint8_t _PyOpcode_InlineCacheEntries[256]; diff --git a/Lib/opcode.py b/Lib/opcode.py index 3675780839671c..690156d7519f82 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -285,6 +285,7 @@ def jabs_op(name, op, entries=0): "PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST", "PRECALL_BOUND_METHOD", "PRECALL_PYFUNC", + "PRECALL_PY_CLASS", "RESUME_QUICK", "STORE_ATTR_ADAPTIVE", "STORE_ATTR_INSTANCE_VALUE", diff --git a/Python/ceval.c b/Python/ceval.c index 0743894c457a7b..211d876ddfafbf 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1587,6 +1587,11 @@ pop_frame(PyThreadState *tstate, _PyInterpreterFrame *frame) */ typedef struct { PyObject *kwnames; + /* __init__ is special because while it returns None, we need to return self + This tells CALL to pass the current self to the new frame (the __init__ frame). + Where it is eventually consumed by RETURN_VALUE. + */ + bool init_pass_self; } CallShape; static inline bool @@ -1618,6 +1623,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyCFrame cframe; CallShape call_shape; call_shape.kwnames = NULL; // Borrowed reference. Reset by CALL instructions. + call_shape.init_pass_self = 0; /* WARNING: Because the _PyCFrame lives on the C stack, * but can be accessed from a heap allocated object (tstate) @@ -2386,6 +2392,18 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int TARGET(RETURN_VALUE) { PyObject *retval = POP(); + if (frame->self != NULL) { + if (Py_IsNone(retval)) { + Py_SETREF(retval, frame->self); + frame->self = NULL; + } + /* We need this to continue raising errors when bad-practice + __init__s return their non-None values. This is later + caught by the interpreter. */ + else { + Py_CLEAR(frame->self); + } + } assert(EMPTY()); frame->f_state = FRAME_RETURNED; _PyFrame_SetStackPointer(frame, stack_pointer); @@ -4617,6 +4635,45 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int DISPATCH(); } + TARGET(PRECALL_PY_CLASS) { + SpecializedCacheEntry *cache = GET_CACHE(); + _PyAdaptiveEntry *cache0 = &cache[0].adaptive; + _PyCallCache *cache1 = &cache[-1].call; + int original_oparg = cache->adaptive.original_oparg; + int is_method = (PEEK(original_oparg + 2) != NULL); + DEOPT_IF(is_method, PRECALL); + PyObject *cls = PEEK(original_oparg + 1); + DEOPT_IF(!PyType_Check(cls), PRECALL); + PyTypeObject *cls_t = (PyTypeObject *)cls; + DEOPT_IF(cls_t->tp_version_tag != cache0->version, PRECALL); + assert(cls_t->tp_flags & Py_TPFLAGS_HEAPTYPE); + PyObject *init = ((PyHeapTypeObject *)cls_t)->_spec_cache.init; + assert(PyFunction_Check(init)); + DEOPT_IF(((PyFunctionObject *)(init))->func_version != cache1->func_version, PRECALL); + DEOPT_IF(cls_t->tp_new != PyBaseObject_Type.tp_new, PRECALL); + STAT_INC(PRECALL, hit); + + PyObject *args = _PyTuple_FromArray(&PEEK(original_oparg), original_oparg); + if (args == NULL) { + goto error; + } + PyObject *self = cls_t->tp_new(cls_t, args, call_shape.kwnames); + Py_DECREF(args); + if (self == NULL) { + goto error; + } + Py_INCREF(init); + PEEK(original_oparg+1) = self; + PEEK(original_oparg+2) = init; + Py_DECREF(cls); + + /* For use in RETURN_VALUE later */ + Py_INCREF(self); + assert(call_shape.init_pass_self == false); + call_shape.init_pass_self = true; + DISPATCH(); + } + TARGET(KW_NAMES) { assert(call_shape.kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(consts)); @@ -4651,6 +4708,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; cframe.current_frame = frame = new_frame; + frame->self = call_shape.init_pass_self ? frame->localsplus[0] : NULL; + call_shape.init_pass_self = false; CALL_STAT_INC(inlined_py_calls); goto start_frame; } @@ -4762,6 +4821,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; frame = cframe.current_frame = new_frame; + frame->self = call_shape.init_pass_self ? frame->localsplus[0] : NULL; + call_shape.init_pass_self = false; goto start_frame; } @@ -4803,6 +4864,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; frame = cframe.current_frame = new_frame; + frame->self = call_shape.init_pass_self ? frame->localsplus[0] : NULL; + call_shape.init_pass_self = false; goto start_frame; } @@ -5247,6 +5310,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int assert(PyTuple_CheckExact(callargs)); result = do_call_core(tstate, func, callargs, kwargs, cframe.use_tracing); + if (call_shape.init_pass_self) { + Py_SETREF(result, PyTuple_GET_ITEM(callargs, 0)); + call_shape.init_pass_self = false; + } Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 2060793b4f1c8a..90ab65707d4bbc 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -142,36 +142,37 @@ static void *opcode_targets[256] = { &&TARGET_PRECALL_BOUND_METHOD, &&TARGET_PRECALL_PYFUNC, &&TARGET_CALL_FUNCTION_EX, - &&TARGET_RESUME_QUICK, + &&TARGET_PRECALL_PY_CLASS, &&TARGET_EXTENDED_ARG, &&TARGET_LIST_APPEND, &&TARGET_SET_ADD, &&TARGET_MAP_ADD, &&TARGET_LOAD_CLASSDEREF, &&TARGET_COPY_FREE_VARS, - &&TARGET_STORE_ATTR_ADAPTIVE, + &&TARGET_RESUME_QUICK, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, + &&TARGET_STORE_ATTR_ADAPTIVE, &&TARGET_STORE_ATTR_INSTANCE_VALUE, - &&TARGET_STORE_ATTR_SLOT, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, + &&TARGET_STORE_ATTR_SLOT, &&TARGET_STORE_ATTR_WITH_HINT, - &&TARGET_UNPACK_SEQUENCE_ADAPTIVE, &&TARGET_LOAD_METHOD, - &&TARGET_UNPACK_SEQUENCE_LIST, + &&TARGET_UNPACK_SEQUENCE_ADAPTIVE, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, &&TARGET_PRECALL, + &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_UNPACK_SEQUENCE_TUPLE, &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_LOAD_FAST__LOAD_FAST, - &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_CALL, &&TARGET_KW_NAMES, + &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_LOAD_FAST__LOAD_CONST, &&TARGET_LOAD_CONST__LOAD_FAST, &&TARGET_STORE_FAST__STORE_FAST, @@ -253,6 +254,5 @@ static void *opcode_targets[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_DO_TRACING }; diff --git a/Python/specialize.c b/Python/specialize.c index 417eece88b86a5..9d861d984625d5 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -591,15 +591,16 @@ initial_counter_value(void) { #define SPEC_FAIL_CALL_BAD_CALL_FLAGS 17 #define SPEC_FAIL_CALL_CLASS 18 #define SPEC_FAIL_CALL_PYTHON_CLASS 19 -#define SPEC_FAIL_CALL_METHOD_DESCRIPTOR 20 -#define SPEC_FAIL_CALL_BOUND_METHOD 21 -#define SPEC_FAIL_CALL_STR 22 -#define SPEC_FAIL_CALL_CLASS_NO_VECTORCALL 23 -#define SPEC_FAIL_CALL_CLASS_MUTABLE 24 -#define SPEC_FAIL_CALL_KWNAMES 25 -#define SPEC_FAIL_CALL_METHOD_WRAPPER 26 -#define SPEC_FAIL_CALL_OPERATOR_WRAPPER 27 -#define SPEC_FAIL_CALL_PYFUNCTION 28 +#define SPEC_FAIL_CALL_PYTHON_CLASS_NON_PY_INIT 20 +#define SPEC_FAIL_CALL_METHOD_DESCRIPTOR 21 +#define SPEC_FAIL_CALL_BOUND_METHOD 22 +#define SPEC_FAIL_CALL_STR 23 +#define SPEC_FAIL_CALL_CLASS_NO_VECTORCALL 24 +#define SPEC_FAIL_CALL_CLASS_MUTABLE 25 +#define SPEC_FAIL_CALL_KWNAMES 26 +#define SPEC_FAIL_CALL_METHOD_WRAPPER 27 +#define SPEC_FAIL_CALL_OPERATOR_WRAPPER 28 +#define SPEC_FAIL_CALL_PYFUNCTION 29 /* COMPARE_OP */ #define SPEC_FAIL_COMPARE_OP_DIFFERENT_TYPES 12 @@ -1523,7 +1524,33 @@ specialize_class_call( assert(_Py_OPCODE(*instr) == PRECALL_ADAPTIVE); PyTypeObject *tp = _PyType_CAST(callable); if (tp->tp_new == PyBaseObject_Type.tp_new) { - SPECIALIZATION_FAIL(PRECALL, SPEC_FAIL_CALL_PYTHON_CLASS); + _PyAdaptiveEntry *cache0 = &cache[0].adaptive; + _PyCallCache *cache1 = &cache[-1].call; + PyObject *descriptor = _PyType_Lookup(tp, &_Py_ID(__init__)); + if (descriptor && Py_TYPE(descriptor) == &PyFunction_Type) { + if (!(tp->tp_flags & Py_TPFLAGS_HEAPTYPE)) { + return -1; + } + PyFunctionObject *func = (PyFunctionObject *)descriptor; + PyCodeObject *fcode = (PyCodeObject *)func->func_code; + int kind = function_kind(fcode); + if (kind != SIMPLE_FUNCTION) { + SPECIALIZATION_FAIL(PRECALL, kind); + return -1; + } + assert(tp->tp_version_tag != 0); + cache0->version = tp->tp_version_tag; + int version = _PyFunction_GetVersionForCurrentState(func); + if (version == 0 || version != (uint16_t)version) { + SPECIALIZATION_FAIL(PRECALL, SPEC_FAIL_OUT_OF_VERSIONS); + return -1; + } + cache1->func_version = version; + ((PyHeapTypeObject *)tp)->_spec_cache.init = descriptor; + *instr = _Py_MAKECODEUNIT(PRECALL_PY_CLASS, _Py_OPARG(*instr)); + return 0; + } + SPECIALIZATION_FAIL(PRECALL, SPEC_FAIL_CALL_PYTHON_CLASS_NON_PY_INIT); return -1; } if (tp->tp_flags & Py_TPFLAGS_IMMUTABLETYPE) { From 09a7180ef99834c67092d63c518e497c43472c05 Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sun, 6 Mar 2022 21:51:56 +0800 Subject: [PATCH 02/13] Add news --- .../Core and Builtins/2022-03-06-21-50-36.bpo-46939.nlQEGG.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-03-06-21-50-36.bpo-46939.nlQEGG.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-03-06-21-50-36.bpo-46939.nlQEGG.rst b/Misc/NEWS.d/next/Core and Builtins/2022-03-06-21-50-36.bpo-46939.nlQEGG.rst new file mode 100644 index 00000000000000..bd335216ce398d --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-03-06-21-50-36.bpo-46939.nlQEGG.rst @@ -0,0 +1,2 @@ +Calls to Python classes are now specialized. Creating objects from Python +classes should now be faster. Patch by Ken Jin. From d74d294c0d4b0e4a87ba7528c51e34eab7ae51c0 Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:22:48 +0800 Subject: [PATCH 03/13] Fix segfaults, refleaks, readjust sys tests size --- Include/internal/pycore_frame.h | 2 +- Lib/test/test_sys.py | 6 +++--- Python/ceval.c | 27 ++++++++++++++++----------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index d4d3a1b7538b6f..1dd233a1a446ac 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -61,7 +61,7 @@ typedef struct _PyInterpreterFrame { PyFrameState f_state; /* What state the frame is in */ bool is_entry; // Whether this is the "root" frame for the current _PyCFrame. bool is_generator; - PyObject *self; /* Strong reference consumed by __init__ frames to return self in RETURN_VALUE */ + PyObject *self; /* Borrowed reference used by __init__ frames to return self in RETURN_VALUE */ PyObject *localsplus[1]; } _PyInterpreterFrame; diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index f4deb1763b95f0..cd9af2e20c7027 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1397,7 +1397,7 @@ class C(object): pass def func(): return sys._getframe() x = func() - check(x, size('3Pi3c7P2ic??2P')) + check(x, size('3Pi3c7P2ic??3P')) # function def func(): pass check(func, size('14Pi')) @@ -1414,7 +1414,7 @@ def bar(cls): check(bar, size('PP')) # generator def get_gen(): yield 1 - check(get_gen(), size('P2P4P4c7P2ic??P')) + check(get_gen(), size('P2P4P4c7P2ic??2P')) # iterator check(iter('abc'), size('lP')) # callable-iterator @@ -1506,7 +1506,7 @@ def delx(self): del self.__x '10P' # PySequenceMethods '2P' # PyBufferProcs '6P' - '1P' # Specializer cache + '2P' # Specializer cache ) class newstyleclass(object): pass # Separate block for PyDictKeysObject with 8 keys and 5 entries diff --git a/Python/ceval.c b/Python/ceval.c index 211d876ddfafbf..419a130c338504 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4668,7 +4668,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int Py_DECREF(cls); /* For use in RETURN_VALUE later */ - Py_INCREF(self); assert(call_shape.init_pass_self == false); call_shape.init_pass_self = true; DISPATCH(); @@ -4708,8 +4707,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; cframe.current_frame = frame = new_frame; - frame->self = call_shape.init_pass_self ? frame->localsplus[0] : NULL; - call_shape.init_pass_self = false; + if (call_shape.init_pass_self) { + assert(frame->self == NULL); + frame->self = Py_NewRef(frame->localsplus[0]); + call_shape.init_pass_self = false; + } CALL_STAT_INC(inlined_py_calls); goto start_frame; } @@ -4821,8 +4823,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; frame = cframe.current_frame = new_frame; - frame->self = call_shape.init_pass_self ? frame->localsplus[0] : NULL; - call_shape.init_pass_self = false; + if (call_shape.init_pass_self) { + assert(frame->self == NULL); + frame->self = Py_NewRef(frame->localsplus[0]); + call_shape.init_pass_self = false; + } goto start_frame; } @@ -4864,8 +4869,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; frame = cframe.current_frame = new_frame; - frame->self = call_shape.init_pass_self ? frame->localsplus[0] : NULL; - call_shape.init_pass_self = false; + if (call_shape.init_pass_self) { + assert(frame->self == NULL); + frame->self = Py_NewRef(frame->localsplus[0]); + call_shape.init_pass_self = false; + } goto start_frame; } @@ -5310,10 +5318,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int assert(PyTuple_CheckExact(callargs)); result = do_call_core(tstate, func, callargs, kwargs, cframe.use_tracing); - if (call_shape.init_pass_self) { - Py_SETREF(result, PyTuple_GET_ITEM(callargs, 0)); - call_shape.init_pass_self = false; - } Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); @@ -5684,6 +5688,7 @@ MISS_WITH_OPARG_COUNTER(STORE_SUBSCR) error: call_shape.kwnames = NULL; + call_shape.init_pass_self = false; /* Double-check exception status. */ #ifdef NDEBUG if (!_PyErr_Occurred(tstate)) { From 0583f6be750eb5d4e317c69fdd0b610cc25defbd Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Mon, 7 Mar 2022 01:09:24 +0800 Subject: [PATCH 04/13] fix refleak on frame exit due to exception --- Python/ceval.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/ceval.c b/Python/ceval.c index 419a130c338504..776887b31b2141 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5730,6 +5730,7 @@ MISS_WITH_OPARG_COUNTER(STORE_SUBSCR) assert(STACK_LEVEL() == 0); _PyFrame_SetStackPointer(frame, stack_pointer); frame->f_state = FRAME_RAISED; + Py_CLEAR(frame->self); TRACE_FUNCTION_UNWIND(); DTRACE_FUNCTION_EXIT(); goto exit_unwind; From bb78e9cd9234084d2e6d6fefd55c2206badf17ff Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Mon, 7 Mar 2022 01:29:32 +0800 Subject: [PATCH 05/13] Use non-function pointer since it's faster --- Python/ceval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/ceval.c b/Python/ceval.c index 776887b31b2141..0d5965b4f88dac 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4657,7 +4657,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int if (args == NULL) { goto error; } - PyObject *self = cls_t->tp_new(cls_t, args, call_shape.kwnames); + PyObject *self = PyBaseObject_Type.tp_new(cls_t, args, call_shape.kwnames); Py_DECREF(args); if (self == NULL) { goto error; From b570e9284ed0f90e4d586e9860df28f063b978bf Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Mon, 7 Mar 2022 17:33:30 +0800 Subject: [PATCH 06/13] Address Jelle's review (use vectorcall for new) --- Include/internal/pycore_typeobject.h | 2 ++ Objects/typeobject.c | 10 +++++++++- Python/ceval.c | 8 ++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Include/internal/pycore_typeobject.h b/Include/internal/pycore_typeobject.h index c480a3a57b436c..393ea3859bc07e 100644 --- a/Include/internal/pycore_typeobject.h +++ b/Include/internal/pycore_typeobject.h @@ -43,6 +43,8 @@ extern PyStatus _PyTypes_InitSlotDefs(void); extern void _PyStaticType_Dealloc(PyTypeObject *type); +extern PyObject *_PyObject_New_Vector(PyTypeObject *type, + PyObject *const *args, Py_ssize_t nargs, PyObject *kwds); #ifdef __cplusplus } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 78795150756130..94fd48fb329f3d 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4514,7 +4514,15 @@ object_init(PyObject *self, PyObject *args, PyObject *kwds) static PyObject * object_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - if (excess_args(args, kwds)) { + return _PyObject_New_Vector(type, (_PyTuple_CAST(args)->ob_item), + PyTuple_GET_SIZE(args), kwds); +} + +PyObject * +_PyObject_New_Vector(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwds) +{ + if (nargs || (kwds && PyDict_Check(kwds) && PyDict_GET_SIZE(kwds))) { if (type->tp_new != object_new) { PyErr_SetString(PyExc_TypeError, "object.__new__() takes exactly one argument (the type to instantiate)"); diff --git a/Python/ceval.c b/Python/ceval.c index 0d5965b4f88dac..d0e18084672a42 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4653,12 +4653,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int DEOPT_IF(cls_t->tp_new != PyBaseObject_Type.tp_new, PRECALL); STAT_INC(PRECALL, hit); - PyObject *args = _PyTuple_FromArray(&PEEK(original_oparg), original_oparg); - if (args == NULL) { - goto error; - } - PyObject *self = PyBaseObject_Type.tp_new(cls_t, args, call_shape.kwnames); - Py_DECREF(args); + PyObject *self = _PyObject_New_Vector(cls_t, &PEEK(original_oparg), + (Py_ssize_t)original_oparg, call_shape.kwnames); if (self == NULL) { goto error; } From efad70f6e5c7446b67a3739f2a962944dd7cf177 Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Mon, 7 Mar 2022 21:15:51 +0800 Subject: [PATCH 07/13] Address Mark's reviews (remove func version check) --- Python/ceval.c | 2 -- Python/specialize.c | 7 ------- 2 files changed, 9 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index d0e18084672a42..3be73ea31e18bf 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4638,7 +4638,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int TARGET(PRECALL_PY_CLASS) { SpecializedCacheEntry *cache = GET_CACHE(); _PyAdaptiveEntry *cache0 = &cache[0].adaptive; - _PyCallCache *cache1 = &cache[-1].call; int original_oparg = cache->adaptive.original_oparg; int is_method = (PEEK(original_oparg + 2) != NULL); DEOPT_IF(is_method, PRECALL); @@ -4649,7 +4648,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int assert(cls_t->tp_flags & Py_TPFLAGS_HEAPTYPE); PyObject *init = ((PyHeapTypeObject *)cls_t)->_spec_cache.init; assert(PyFunction_Check(init)); - DEOPT_IF(((PyFunctionObject *)(init))->func_version != cache1->func_version, PRECALL); DEOPT_IF(cls_t->tp_new != PyBaseObject_Type.tp_new, PRECALL); STAT_INC(PRECALL, hit); diff --git a/Python/specialize.c b/Python/specialize.c index 9d861d984625d5..e1779b32d667c5 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1525,7 +1525,6 @@ specialize_class_call( PyTypeObject *tp = _PyType_CAST(callable); if (tp->tp_new == PyBaseObject_Type.tp_new) { _PyAdaptiveEntry *cache0 = &cache[0].adaptive; - _PyCallCache *cache1 = &cache[-1].call; PyObject *descriptor = _PyType_Lookup(tp, &_Py_ID(__init__)); if (descriptor && Py_TYPE(descriptor) == &PyFunction_Type) { if (!(tp->tp_flags & Py_TPFLAGS_HEAPTYPE)) { @@ -1540,12 +1539,6 @@ specialize_class_call( } assert(tp->tp_version_tag != 0); cache0->version = tp->tp_version_tag; - int version = _PyFunction_GetVersionForCurrentState(func); - if (version == 0 || version != (uint16_t)version) { - SPECIALIZATION_FAIL(PRECALL, SPEC_FAIL_OUT_OF_VERSIONS); - return -1; - } - cache1->func_version = version; ((PyHeapTypeObject *)tp)->_spec_cache.init = descriptor; *instr = _Py_MAKECODEUNIT(PRECALL_PY_CLASS, _Py_OPARG(*instr)); return 0; From 4d6a06b6519895e96de03898992bd0acdad6e0a8 Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Mon, 7 Mar 2022 21:21:39 +0800 Subject: [PATCH 08/13] Use a macro for passing self --- Python/ceval.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 3be73ea31e18bf..5129942f1d0a56 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1462,6 +1462,13 @@ eval_frame_handle_pending(PyThreadState *tstate) STAT_INC(LOAD_##attr_or_method, hit); \ Py_INCREF(res); +#define CALL_PY_FRAME_PASS_SELF() \ + if (call_shape.init_pass_self) { \ + assert(frame->self == NULL); \ + frame->self = Py_NewRef(frame->localsplus[0]); \ + call_shape.init_pass_self = false; \ + } + #define TRACE_FUNCTION_EXIT() \ if (cframe.use_tracing) { \ if (trace_function_exit(tstate, frame, retval)) { \ @@ -4701,11 +4708,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; cframe.current_frame = frame = new_frame; - if (call_shape.init_pass_self) { - assert(frame->self == NULL); - frame->self = Py_NewRef(frame->localsplus[0]); - call_shape.init_pass_self = false; - } + CALL_PY_FRAME_PASS_SELF(); CALL_STAT_INC(inlined_py_calls); goto start_frame; } @@ -4817,11 +4820,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; frame = cframe.current_frame = new_frame; - if (call_shape.init_pass_self) { - assert(frame->self == NULL); - frame->self = Py_NewRef(frame->localsplus[0]); - call_shape.init_pass_self = false; - } + CALL_PY_FRAME_PASS_SELF(); goto start_frame; } @@ -4863,11 +4862,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int _PyFrame_SetStackPointer(frame, stack_pointer); new_frame->previous = frame; frame = cframe.current_frame = new_frame; - if (call_shape.init_pass_self) { - assert(frame->self == NULL); - frame->self = Py_NewRef(frame->localsplus[0]); - call_shape.init_pass_self = false; - } + CALL_PY_FRAME_PASS_SELF(); goto start_frame; } From de3a406a11c0e67df4769026a53ca10c54d071d2 Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Tue, 8 Mar 2022 17:44:07 +0800 Subject: [PATCH 09/13] Use inline caching --- Include/internal/pycore_code.h | 1 + Include/opcode.h | 2 +- Lib/importlib/_bootstrap_external.py | 3 ++- Lib/opcode.py | 2 +- Python/ceval.c | 19 +++++++++---------- Python/specialize.c | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 21c657afed6c8f..48265a475e386c 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -82,6 +82,7 @@ typedef struct { typedef struct { _Py_CODEUNIT counter; + _Py_CODEUNIT type_version[2]; } _PyPrecallCache; #define INLINE_CACHE_ENTRIES_PRECALL CACHE_ENTRIES(_PyPrecallCache) diff --git a/Include/opcode.h b/Include/opcode.h index 5ef9c12437d3fb..c3082991f2a138 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -219,7 +219,7 @@ const uint8_t _PyOpcode_InlineCacheEntries[256] = { [LOAD_GLOBAL] = 5, [BINARY_OP] = 1, [LOAD_METHOD] = 10, - [PRECALL] = 1, + [PRECALL] = 3, [CALL] = 4, }; #endif /* OPCODE_TABLES */ diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 32a41f852e5d7e..f5543e6eaeb1e4 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -394,6 +394,7 @@ def _write_atomic(path, data, mode=0o666): # STORE_ATTR) # Python 3.11a5 3485 (Add an oparg to GET_AWAITABLE) # Python 3.11a6 3486 (Use inline caching for PRECALL and CALL) +# Python 3.11a6 3487 (Specialize PRECALL for Python classes) # Python 3.12 will start with magic number 3500 @@ -408,7 +409,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3486).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3487).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 1e3a3130bd9880..d833c82c16e6c5 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -191,7 +191,7 @@ def jabs_op(name, op, entries=0): def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -def_op('PRECALL', 166, 1) +def_op('PRECALL', 166, 3) def_op('CALL', 171, 4) def_op('KW_NAMES', 172) diff --git a/Python/ceval.c b/Python/ceval.c index 92b73fdb676dbc..70b2abed4f2745 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4633,34 +4633,33 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int } TARGET(PRECALL_PY_CLASS) { - SpecializedCacheEntry *cache = GET_CACHE(); - _PyAdaptiveEntry *cache0 = &cache[0].adaptive; - int original_oparg = cache->adaptive.original_oparg; - int is_method = (PEEK(original_oparg + 2) != NULL); + _PyPrecallCache *cache = (_PyPrecallCache *)next_instr; + int is_method = (PEEK(oparg + 2) != NULL); DEOPT_IF(is_method, PRECALL); - PyObject *cls = PEEK(original_oparg + 1); + PyObject *cls = PEEK(oparg + 1); DEOPT_IF(!PyType_Check(cls), PRECALL); PyTypeObject *cls_t = (PyTypeObject *)cls; - DEOPT_IF(cls_t->tp_version_tag != cache0->version, PRECALL); + DEOPT_IF(cls_t->tp_version_tag != read_u32(cache->type_version), PRECALL); assert(cls_t->tp_flags & Py_TPFLAGS_HEAPTYPE); PyObject *init = ((PyHeapTypeObject *)cls_t)->_spec_cache.init; assert(PyFunction_Check(init)); DEOPT_IF(cls_t->tp_new != PyBaseObject_Type.tp_new, PRECALL); STAT_INC(PRECALL, hit); - PyObject *self = _PyObject_New_Vector(cls_t, &PEEK(original_oparg), - (Py_ssize_t)original_oparg, call_shape.kwnames); + PyObject *self = _PyObject_New_Vector(cls_t, &PEEK(oparg), + (Py_ssize_t)oparg, call_shape.kwnames); if (self == NULL) { goto error; } Py_INCREF(init); - PEEK(original_oparg+1) = self; - PEEK(original_oparg+2) = init; + PEEK(oparg+1) = self; + PEEK(oparg+2) = init; Py_DECREF(cls); /* For use in RETURN_VALUE later */ assert(call_shape.init_pass_self == false); call_shape.init_pass_self = true; + JUMPBY(INLINE_CACHE_ENTRIES_PRECALL); DISPATCH(); } diff --git a/Python/specialize.c b/Python/specialize.c index 44b9fab7519e2a..5da949f9fae172 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1422,7 +1422,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, assert(_Py_OPCODE(*instr) == PRECALL_ADAPTIVE); PyTypeObject *tp = _PyType_CAST(callable); if (tp->tp_new == PyBaseObject_Type.tp_new) { - _PyAdaptiveEntry *cache0 = &cache[0].adaptive; + _PyPrecallCache *cache = (_PyPrecallCache *)(instr + 1); PyObject *descriptor = _PyType_Lookup(tp, &_Py_ID(__init__)); if (descriptor && Py_TYPE(descriptor) == &PyFunction_Type) { if (!(tp->tp_flags & Py_TPFLAGS_HEAPTYPE)) { @@ -1436,7 +1436,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, return -1; } assert(tp->tp_version_tag != 0); - cache0->version = tp->tp_version_tag; + write_u32(cache->type_version, tp->tp_version_tag); ((PyHeapTypeObject *)tp)->_spec_cache.init = descriptor; *instr = _Py_MAKECODEUNIT(PRECALL_PY_CLASS, _Py_OPARG(*instr)); return 0; From 30a06590d036cb549ce5a9a7ef4858f48bb98e0a Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Tue, 8 Mar 2022 17:55:19 +0800 Subject: [PATCH 10/13] Regenerate frozenmain --- Programs/test_frozenmain.h | 46 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index 8cae77a4899f12..aa9e5ccce30081 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -1,18 +1,19 @@ // Auto-generated by Programs/freeze_test_frozenmain.py unsigned char M_test_frozenmain[] = { 227,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0, - 0,0,0,0,0,115,176,0,0,0,151,0,100,0,100,1, + 0,0,0,0,0,115,192,0,0,0,151,0,100,0,100,1, 108,0,90,0,100,0,100,1,108,1,90,1,2,0,101,2, - 100,2,166,1,0,0,171,1,0,0,0,0,0,0,0,0, - 1,0,2,0,101,2,100,3,101,0,106,3,0,0,0,0, - 0,0,0,0,166,2,0,0,171,2,0,0,0,0,0,0, - 0,0,1,0,2,0,101,1,106,4,0,0,0,0,0,0, - 0,0,166,0,0,0,171,0,0,0,0,0,0,0,0,0, - 100,4,25,0,0,0,0,0,0,0,0,0,90,5,100,5, - 68,0,93,25,90,6,2,0,101,2,100,6,101,6,155,0, - 100,7,101,5,101,6,25,0,0,0,0,0,0,0,0,0, - 155,0,157,4,166,1,0,0,171,1,0,0,0,0,0,0, - 0,0,1,0,113,60,100,1,83,0,41,8,233,0,0,0, + 100,2,166,1,0,0,0,0,0,0,171,1,0,0,0,0, + 0,0,0,0,1,0,2,0,101,2,100,3,101,0,106,3, + 0,0,0,0,0,0,0,0,166,2,0,0,0,0,0,0, + 171,2,0,0,0,0,0,0,0,0,1,0,2,0,101,1, + 106,4,0,0,0,0,0,0,0,0,166,0,0,0,0,0, + 0,0,171,0,0,0,0,0,0,0,0,0,100,4,25,0, + 0,0,0,0,0,0,0,0,90,5,100,5,68,0,93,27, + 90,6,2,0,101,2,100,6,101,6,155,0,100,7,101,5, + 101,6,25,0,0,0,0,0,0,0,0,0,155,0,157,4, + 166,1,0,0,0,0,0,0,171,1,0,0,0,0,0,0, + 0,0,1,0,113,66,100,1,83,0,41,8,233,0,0,0, 0,78,122,18,70,114,111,122,101,110,32,72,101,108,108,111, 32,87,111,114,108,100,122,8,115,121,115,46,97,114,103,118, 218,6,99,111,110,102,105,103,41,5,90,12,112,114,111,103, @@ -28,19 +29,20 @@ unsigned char M_test_frozenmain[] = { 107,101,121,169,0,243,0,0,0,0,250,18,116,101,115,116, 95,102,114,111,122,101,110,109,97,105,110,46,112,121,250,8, 60,109,111,100,117,108,101,62,114,11,0,0,0,1,0,0, - 0,115,18,0,0,0,2,128,8,3,8,1,22,2,34,1, - 42,1,8,1,48,7,4,249,115,20,0,0,0,2,128,8, - 3,8,1,22,2,34,1,42,1,2,7,4,1,2,249,52, - 7,115,176,0,0,0,0,0,1,11,1,11,1,11,1,11, + 0,115,18,0,0,0,2,128,8,3,8,1,26,2,38,1, + 46,1,8,1,52,7,4,249,115,20,0,0,0,2,128,8, + 3,8,1,26,2,38,1,46,1,2,7,4,1,2,249,56, + 7,115,192,0,0,0,0,0,1,11,1,11,1,11,1,11, 1,25,1,25,1,25,1,25,1,6,1,6,7,27,1,28, - 1,28,1,28,1,28,1,28,1,28,1,28,1,28,1,6, - 1,6,7,17,19,22,19,27,19,27,19,27,19,27,19,27, 1,28,1,28,1,28,1,28,1,28,1,28,1,28,1,28, - 10,39,10,27,10,39,10,39,10,39,10,39,10,39,10,41, - 10,41,10,41,10,41,10,41,10,41,10,41,42,50,10,51, - 10,51,10,51,10,51,10,51,1,7,12,2,1,42,1,42, - 5,8,5,10,5,10,11,41,21,24,11,41,11,41,28,34, - 35,38,28,39,28,39,28,39,28,39,28,39,11,41,11,41, + 1,28,1,6,1,6,7,17,19,22,19,27,19,27,19,27, + 19,27,19,27,1,28,1,28,1,28,1,28,1,28,1,28, + 1,28,1,28,1,28,1,28,10,39,10,27,10,39,10,39, + 10,39,10,39,10,39,10,41,10,41,10,41,10,41,10,41, + 10,41,10,41,10,41,10,41,42,50,10,51,10,51,10,51, + 10,51,10,51,1,7,12,2,1,42,1,42,5,8,5,10, + 5,10,11,41,21,24,11,41,11,41,28,34,35,38,28,39, + 28,39,28,39,28,39,28,39,11,41,11,41,5,42,5,42, 5,42,5,42,5,42,5,42,5,42,5,42,5,42,5,42, 5,42,1,42,1,42,114,9,0,0,0, }; From db09eefbfd180d9e4e144ea64cf8500ede237c21 Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Tue, 8 Mar 2022 18:46:05 +0800 Subject: [PATCH 11/13] Fix test_dis --- Lib/test/test_dis.py | 298 +++++++++++++++++++++---------------------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 12d46af208e0a1..292da31e6f9e8b 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -149,10 +149,10 @@ def bug708901(): %3d PRECALL 2 CALL 2 GET_ITER - >> FOR_ITER 2 (to 42) + >> FOR_ITER 2 (to 46) STORE_FAST 0 (res) -%3d JUMP_ABSOLUTE 18 (to 36) +%3d JUMP_ABSOLUTE 20 (to 40) %3d >> LOAD_CONST 0 (None) RETURN_VALUE @@ -1164,10 +1164,10 @@ def _prepare_test_cases(): Instruction(opname='BUILD_MAP', opcode=105, arg=0, argval=0, argrepr='', offset=44, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Hello world!', argrepr="'Hello world!'", offset=46, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='PRECALL', opcode=166, arg=7, argval=7, argrepr='', offset=48, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=7, argval=7, argrepr='', offset=52, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=62, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='f', argrepr='f', offset=64, starts_line=8, is_jump_target=False, positions=None), - Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=66, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=7, argval=7, argrepr='', offset=56, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=66, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='f', argrepr='f', offset=68, starts_line=8, is_jump_target=False, positions=None), + Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=70, starts_line=None, is_jump_target=False, positions=None), ] expected_opinfo_f = [ @@ -1191,10 +1191,10 @@ def _prepare_test_cases(): Instruction(opname='LOAD_DEREF', opcode=137, arg=0, argval='c', argrepr='c', offset=44, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='LOAD_DEREF', opcode=137, arg=1, argval='d', argrepr='d', offset=46, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='PRECALL', opcode=166, arg=4, argval=4, argrepr='', offset=48, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=4, argval=4, argrepr='', offset=52, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=62, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='inner', argrepr='inner', offset=64, starts_line=6, is_jump_target=False, positions=None), - Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=66, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=4, argval=4, argrepr='', offset=56, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=66, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='inner', argrepr='inner', offset=68, starts_line=6, is_jump_target=False, positions=None), + Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=70, starts_line=None, is_jump_target=False, positions=None), ] expected_opinfo_inner = [ @@ -1209,10 +1209,10 @@ def _prepare_test_cases(): Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='e', argrepr='e', offset=26, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='LOAD_FAST', opcode=124, arg=1, argval='f', argrepr='f', offset=28, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='PRECALL', opcode=166, arg=6, argval=6, argrepr='', offset=30, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=6, argval=6, argrepr='', offset=34, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=44, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=46, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=48, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=6, argval=6, argrepr='', offset=38, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=48, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=50, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=52, starts_line=None, is_jump_target=False, positions=None), ] expected_opinfo_jumpy = [ Instruction(opname='RESUME', opcode=151, arg=0, argval=0, argrepr='', offset=0, starts_line=1, is_jump_target=False, positions=None), @@ -1220,141 +1220,141 @@ def _prepare_test_cases(): Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='range', argrepr='range', offset=4, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=10, argrepr='10', offset=16, starts_line=None, is_jump_target=False, positions=None), Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=18, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=22, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='GET_ITER', opcode=68, arg=None, argval=None, argrepr='', offset=32, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='FOR_ITER', opcode=93, arg=33, argval=102, argrepr='to 102', offset=34, starts_line=None, is_jump_target=True, positions=None), - Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=36, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=38, starts_line=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=40, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=52, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=54, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=58, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=68, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=70, starts_line=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=72, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=74, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=42, argval=84, argrepr='to 84', offset=80, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=17, argval=34, argrepr='to 34', offset=82, starts_line=6, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=84, starts_line=7, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=86, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=88, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=50, argval=100, argrepr='to 100', offset=94, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=96, starts_line=8, is_jump_target=False, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=110, arg=17, argval=134, argrepr='to 134', offset=98, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=17, argval=34, argrepr='to 34', offset=100, starts_line=7, is_jump_target=True, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=102, starts_line=10, is_jump_target=True, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=104, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=116, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=118, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=122, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=132, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=134, starts_line=11, is_jump_target=True, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=106, argval=212, argrepr='to 212', offset=136, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=138, starts_line=12, is_jump_target=True, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=140, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=152, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=154, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=158, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=168, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=170, starts_line=13, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=172, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='BINARY_OP', opcode=122, arg=23, argval=23, argrepr='-=', offset=174, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=178, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=180, starts_line=14, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=182, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=184, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=97, argval=194, argrepr='to 194', offset=190, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=67, argval=134, argrepr='to 134', offset=192, starts_line=15, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=194, starts_line=16, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=196, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=198, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=104, argval=208, argrepr='to 208', offset=204, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=110, arg=18, argval=244, argrepr='to 244', offset=206, starts_line=17, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=208, starts_line=11, is_jump_target=True, positions=None), - Instruction(opname='POP_JUMP_IF_TRUE', opcode=115, arg=69, argval=138, argrepr='to 138', offset=210, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=212, starts_line=19, is_jump_target=True, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=214, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=226, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=228, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=232, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=242, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='NOP', opcode=9, arg=None, argval=None, argrepr='', offset=244, starts_line=20, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=246, starts_line=21, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval=0, argrepr='0', offset=248, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='BINARY_OP', opcode=122, arg=11, argval=11, argrepr='/', offset=250, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=254, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=256, starts_line=25, is_jump_target=False, positions=None), - Instruction(opname='BEFORE_WITH', opcode=53, arg=None, argval=None, argrepr='', offset=258, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=125, arg=1, argval='dodgy', argrepr='dodgy', offset=260, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=262, starts_line=26, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=264, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval='Never reach this', argrepr="'Never reach this'", offset=276, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=278, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=282, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=292, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=294, starts_line=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=296, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=298, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=2, argval=2, argrepr='', offset=300, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=2, argval=2, argrepr='', offset=304, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=314, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=110, arg=11, argval=340, argrepr='to 340', offset=316, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_EXC_INFO', opcode=35, arg=None, argval=None, argrepr='', offset=318, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='WITH_EXCEPT_START', opcode=49, arg=None, argval=None, argrepr='', offset=320, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_TRUE', opcode=115, arg=166, argval=332, argrepr='to 332', offset=322, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=119, arg=2, argval=2, argrepr='', offset=324, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='COPY', opcode=120, arg=3, argval=3, argrepr='', offset=326, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=328, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=119, arg=1, argval=1, argrepr='', offset=330, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=332, starts_line=None, is_jump_target=True, positions=None), - Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=334, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=336, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=338, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=110, arg=31, argval=404, argrepr='to 404', offset=340, starts_line=None, is_jump_target=True, positions=None), - Instruction(opname='PUSH_EXC_INFO', opcode=35, arg=None, argval=None, argrepr='', offset=342, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=2, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=344, starts_line=22, is_jump_target=False, positions=None), - Instruction(opname='JUMP_IF_NOT_EXC_MATCH', opcode=121, arg=198, argval=396, argrepr='to 396', offset=356, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=358, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=360, starts_line=23, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=362, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=9, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=374, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=376, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=380, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=390, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=392, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=110, arg=22, argval=440, argrepr='to 440', offset=394, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=119, arg=0, argval=0, argrepr='', offset=396, starts_line=22, is_jump_target=True, positions=None), - Instruction(opname='COPY', opcode=120, arg=3, argval=3, argrepr='', offset=398, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=400, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=119, arg=1, argval=1, argrepr='', offset=402, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=404, starts_line=28, is_jump_target=True, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=406, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=418, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=420, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=424, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=434, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=436, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=438, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='NOP', opcode=9, arg=None, argval=None, argrepr='', offset=440, starts_line=23, is_jump_target=True, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=442, starts_line=28, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=444, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=456, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=458, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=462, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=472, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=474, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=476, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_EXC_INFO', opcode=35, arg=None, argval=None, argrepr='', offset=478, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=480, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=482, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=494, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=496, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=500, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=510, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=119, arg=0, argval=0, argrepr='', offset=512, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='COPY', opcode=120, arg=3, argval=3, argrepr='', offset=514, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=516, starts_line=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=119, arg=1, argval=1, argrepr='', offset=518, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=26, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='GET_ITER', opcode=68, arg=None, argval=None, argrepr='', offset=36, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='FOR_ITER', opcode=93, arg=35, argval=110, argrepr='to 110', offset=38, starts_line=None, is_jump_target=True, positions=None), + Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=40, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=42, starts_line=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=44, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=56, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=58, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=66, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=76, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=78, starts_line=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=80, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=82, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=46, argval=92, argrepr='to 92', offset=88, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=19, argval=38, argrepr='to 38', offset=90, starts_line=6, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=92, starts_line=7, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=94, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=96, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=54, argval=108, argrepr='to 108', offset=102, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=104, starts_line=8, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=110, arg=19, argval=146, argrepr='to 146', offset=106, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=19, argval=38, argrepr='to 38', offset=108, starts_line=7, is_jump_target=True, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=110, starts_line=10, is_jump_target=True, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=112, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=124, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=126, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=134, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=144, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=146, starts_line=11, is_jump_target=True, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=114, argval=228, argrepr='to 228', offset=148, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=150, starts_line=12, is_jump_target=True, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=152, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=164, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=166, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=174, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=184, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=186, starts_line=13, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=188, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='BINARY_OP', opcode=122, arg=23, argval=23, argrepr='-=', offset=190, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=194, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=196, starts_line=14, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=198, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=200, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=105, argval=210, argrepr='to 210', offset=206, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=73, argval=146, argrepr='to 146', offset=208, starts_line=15, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=210, starts_line=16, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=212, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=214, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=112, argval=224, argrepr='to 224', offset=220, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=110, arg=20, argval=264, argrepr='to 264', offset=222, starts_line=17, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=224, starts_line=11, is_jump_target=True, positions=None), + Instruction(opname='POP_JUMP_IF_TRUE', opcode=115, arg=75, argval=150, argrepr='to 150', offset=226, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=228, starts_line=19, is_jump_target=True, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=230, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=242, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=244, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=252, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=262, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='NOP', opcode=9, arg=None, argval=None, argrepr='', offset=264, starts_line=20, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=266, starts_line=21, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval=0, argrepr='0', offset=268, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='BINARY_OP', opcode=122, arg=11, argval=11, argrepr='/', offset=270, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=274, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=276, starts_line=25, is_jump_target=False, positions=None), + Instruction(opname='BEFORE_WITH', opcode=53, arg=None, argval=None, argrepr='', offset=278, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=125, arg=1, argval='dodgy', argrepr='dodgy', offset=280, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=282, starts_line=26, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=284, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval='Never reach this', argrepr="'Never reach this'", offset=296, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=298, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=306, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=316, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=318, starts_line=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=320, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=322, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=2, argval=2, argrepr='', offset=324, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=2, argval=2, argrepr='', offset=332, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=342, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=110, arg=11, argval=368, argrepr='to 368', offset=344, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_EXC_INFO', opcode=35, arg=None, argval=None, argrepr='', offset=346, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='WITH_EXCEPT_START', opcode=49, arg=None, argval=None, argrepr='', offset=348, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_TRUE', opcode=115, arg=180, argval=360, argrepr='to 360', offset=350, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=119, arg=2, argval=2, argrepr='', offset=352, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='COPY', opcode=120, arg=3, argval=3, argrepr='', offset=354, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=356, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=119, arg=1, argval=1, argrepr='', offset=358, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=360, starts_line=None, is_jump_target=True, positions=None), + Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=362, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=364, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=366, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=110, arg=33, argval=436, argrepr='to 436', offset=368, starts_line=None, is_jump_target=True, positions=None), + Instruction(opname='PUSH_EXC_INFO', opcode=35, arg=None, argval=None, argrepr='', offset=370, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=2, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=372, starts_line=22, is_jump_target=False, positions=None), + Instruction(opname='JUMP_IF_NOT_EXC_MATCH', opcode=121, arg=214, argval=428, argrepr='to 428', offset=384, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=386, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=388, starts_line=23, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=390, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=9, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=402, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=404, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=412, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=422, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=424, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=110, arg=24, argval=476, argrepr='to 476', offset=426, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=119, arg=0, argval=0, argrepr='', offset=428, starts_line=22, is_jump_target=True, positions=None), + Instruction(opname='COPY', opcode=120, arg=3, argval=3, argrepr='', offset=430, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=432, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=119, arg=1, argval=1, argrepr='', offset=434, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=436, starts_line=28, is_jump_target=True, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=438, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=450, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=452, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=460, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=470, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=472, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=474, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='NOP', opcode=9, arg=None, argval=None, argrepr='', offset=476, starts_line=23, is_jump_target=True, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=478, starts_line=28, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=480, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=492, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=494, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=502, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=512, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=514, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=516, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_EXC_INFO', opcode=35, arg=None, argval=None, argrepr='', offset=518, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PUSH_NULL', opcode=2, arg=None, argval=None, argrepr='', offset=520, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=522, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=534, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='PRECALL', opcode=166, arg=1, argval=1, argrepr='', offset=536, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='CALL', opcode=171, arg=1, argval=1, argrepr='', offset=544, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=554, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=119, arg=0, argval=0, argrepr='', offset=556, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='COPY', opcode=120, arg=3, argval=3, argrepr='', offset=558, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=560, starts_line=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=119, arg=1, argval=1, argrepr='', offset=562, starts_line=None, is_jump_target=False, positions=None), ] # One last piece of inspect fodder to check the default line number handling From 28f9dbbe017d3b3fee29fab7812581ca14f4b66d Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Wed, 9 Mar 2022 00:37:28 +0800 Subject: [PATCH 12/13] Drop generators from specialization --- Python/specialize.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Python/specialize.c b/Python/specialize.c index 12ea62aeb0d753..bccee18a1823b9 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1435,6 +1435,10 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, SPECIALIZATION_FAIL(PRECALL, kind); return -1; } + if (fcode->co_flags & (CO_GENERATOR | CO_COROUTINE | + CO_ITERABLE_COROUTINE | CO_ASYNC_GENERATOR)) { + return -1; + } assert(tp->tp_version_tag != 0); write_u32(cache->type_version, tp->tp_version_tag); ((PyHeapTypeObject *)tp)->_spec_cache.init = descriptor; From c04f5daa4327ee44d3d0b9ab56cdf2d860367e1c Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 12 Mar 2022 11:33:21 +0800 Subject: [PATCH 13/13] Use _Py_SET_OPCODE --- Python/specialize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/specialize.c b/Python/specialize.c index df3adbae79e940..f95dc67a1c77fc 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1437,7 +1437,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, assert(tp->tp_version_tag != 0); write_u32(cache->type_version, tp->tp_version_tag); ((PyHeapTypeObject *)tp)->_spec_cache.init = descriptor; - *instr = _Py_MAKECODEUNIT(PRECALL_PY_CLASS, _Py_OPARG(*instr)); + _Py_SET_OPCODE(*instr, PRECALL_PY_CLASS); return 0; } SPECIALIZATION_FAIL(PRECALL, SPEC_FAIL_CALL_PYTHON_CLASS_NON_PY_INIT); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy