This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Break up the YIELD_FROM instruction.
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Mark.Shannon
Priority: normal Keywords: patch

Created on 2021-12-10 17:48 by Mark.Shannon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30035 merged Mark.Shannon, 2021-12-10 17:53
Messages (2)
msg408232 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-10 17:48
The YIELD_FROM instruction does three things:

* It sends a value to the sub-iterator
* It yields the value from the sub-iterator back up to its caller
* Loops back on itself

So we should implement this as:

SEND        <--+
YIELD_VALUE    |
JUMP_ABSOLUTE -+

Doing so would allow us to simplify gen.send and gen.throw as they wouldn't need all the special cases for 'yield from'.

Zero cost exception handling allows us to handle throw in the bytecode with no runtime overhead:

while True:
    SEND -> exit
    try:
        YIELD_VALUE
    except BaseException as ex:
        sub_iterator.throw(ex)
exit:
msg408593 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-15 10:30
New changeset 0b50a4f0cdee41a18fb4ba6e75569f9cfaceb39e by Mark Shannon in branch 'main':
bpo-46039: Split yield from in two (GH-30035)
https://github.com/python/cpython/commit/0b50a4f0cdee41a18fb4ba6e75569f9cfaceb39e
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90197
2022-01-06 12:53:07Mark.Shannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-12-15 10:30:22Mark.Shannonsetmessages: + msg408593
2021-12-10 17:53:12Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28260
2021-12-10 17:48:52Mark.Shannoncreate