We want to be able to specialize iteration over generators and awaiting coroutines. Both for PEP 659 and for higher tier optimizers. For the theory see https://github.com/faster-cpython/ideas/issues/457 To do this we need: - [x] Shim frames to keep the various returns simple https://github.com/python/cpython/pull/96319 - [x] Modify `FOR_ITER` to leave iterator and value on the stack when exiting https://github.com/python/cpython/pull/96801 - [x] Implement specialization of `FOR_ITER` for generators https://github.com/python/cpython/pull/98772 - [x] Implement specialization of `SEND` for coroutines Edited: Remove the requirement for a `GEN_RETURN_VALUE` instruction. We might want one to simplify frame popping, but it isn't needed for specializing. <!-- gh-pr-number: gh-99006 --> * PR: gh-99006 <!-- /gh-pr-number --> <!-- gh-pr-number: gh-98772 --> * PR: gh-98772 <!-- /gh-pr-number -->
We want to be able to specialize iteration over generators and awaiting coroutines. Both for PEP 659 and for higher tier optimizers.
For the theory see faster-cpython/ideas#457
To do this we need:
FOR_ITERto leave iterator and value on the stack when exiting GH-96793: ChangeFOR_ITERto not pop the iterator on exhaustion. #96801FOR_ITERfor generators GH-96793: Specialize FOR_ITER for generators. #98772SENDfor coroutinesEdited:
Remove the requirement for a
GEN_RETURN_VALUEinstruction. We might want one to simplify frame popping, but it isn't needed for specializing.