From 745238c22d28014d20af96e68207d4b6321a51ce Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 20 Oct 2025 23:28:16 +0900 Subject: [PATCH] gh-140205: Add a description of SEND_GEN to the dis module. --- Doc/library/dis.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 284eeff5e4dc7e..bc548b0a15191e 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1809,6 +1809,22 @@ iterations of the loop. .. versionadded:: 3.11 +.. opcode:: SEND_GEN (delta) + + Specialized version of :opcode:`SEND` for generator and coroutine objects. + This is an optimized form that directly executes the generator frame without + the overhead of a full method call. + + Equivalent to ``STACK[-1] = STACK[-2].send(STACK[-1])`` when ``STACK[-2]`` + is a generator or coroutine object in a valid state. + + If the call raises :exc:`StopIteration`, pop the top value from the stack, + push the exception's ``value`` attribute, and increment the bytecode counter + by *delta*. + + .. versionadded:: 3.12 + + .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between