diff options
author | Mark Shannon <mark@hotpy.org> | 2022-01-24 11:08:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-24 11:08:53 (GMT) |
commit | 0367a36fdc36b9c909c4d5acf7cde6ceeec0ba69 (patch) | |
tree | 1a87e9cb04dca5ef87abc4bd55540bdb41bd2172 /Python/ceval.c | |
parent | d75a51bea3c2442f81d38ff850b81b8b7f3330f0 (diff) | |
download | cpython-0367a36fdc36b9c909c4d5acf7cde6ceeec0ba69.zip cpython-0367a36fdc36b9c909c4d5acf7cde6ceeec0ba69.tar.gz cpython-0367a36fdc36b9c909c4d5acf7cde6ceeec0ba69.tar.bz2 |
bpo-43683: Streamline YIELD_VALUE and SEND (GH-30723)
* Split YIELD_VALUE into ASYNC_GEN_WRAP; YIELD_VALUE for async generators.
* Split SEND into SEND; YIELD_VALUE.
* Document new opcodes.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 9aaddd9..2c524ab 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2650,32 +2650,25 @@ handle_eval_breaker: } assert (gen_status == PYGEN_NEXT); assert (retval != NULL); - frame->f_state = FRAME_SUSPENDED; - _PyFrame_SetStackPointer(frame, stack_pointer); - TRACE_FUNCTION_EXIT(); - DTRACE_FUNCTION_EXIT(); - _Py_LeaveRecursiveCall(tstate); - /* Restore previous cframe and return. */ - tstate->cframe = cframe.previous; - tstate->cframe->use_tracing = cframe.use_tracing; - assert(tstate->cframe->current_frame == frame->previous); - assert(!_PyErr_Occurred(tstate)); - return retval; + PUSH(retval); + DISPATCH(); + } + + TARGET(ASYNC_GEN_WRAP) { + PyObject *v = TOP(); + assert(frame->f_code->co_flags & CO_ASYNC_GENERATOR); + PyObject *w = _PyAsyncGenValueWrapperNew(v); + if (w == NULL) { + goto error; + } + SET_TOP(w); + Py_DECREF(v); + DISPATCH(); } TARGET(YIELD_VALUE) { assert(frame->is_entry); PyObject *retval = POP(); - - if (frame->f_code->co_flags & CO_ASYNC_GENERATOR) { - PyObject *w = _PyAsyncGenValueWrapperNew(retval); - Py_DECREF(retval); - if (w == NULL) { - retval = NULL; - goto error; - } - retval = w; - } frame->f_state = FRAME_SUSPENDED; _PyFrame_SetStackPointer(frame, stack_pointer); TRACE_FUNCTION_EXIT(); |