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.

Author Mark.Shannon
Recipients Mark.Shannon
Date 2021-12-10.17:48:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639158532.51.0.938199888812.issue46039@roundup.psfhosted.org>
In-reply-to
Content
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:
History
Date User Action Args
2021-12-10 17:48:52Mark.Shannonsetrecipients: + Mark.Shannon
2021-12-10 17:48:52Mark.Shannonsetmessageid: <1639158532.51.0.938199888812.issue46039@roundup.psfhosted.org>
2021-12-10 17:48:52Mark.Shannonlinkissue46039 messages
2021-12-10 17:48:52Mark.Shannoncreate