New submission from Mark Shannon <m...@hotpy.org>:
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: ---------- assignee: Mark.Shannon components: Interpreter Core messages: 408232 nosy: Mark.Shannon priority: normal severity: normal status: open title: Break up the YIELD_FROM instruction. versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46039> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com