Skip to content

Conversation

@markshannon
Copy link
Member

@markshannon markshannon commented Jan 8, 2026

  • Moves the GET_ITER instruction into the generator function preamble. This means the the iterable is converted into an iterator during generator creation, as documented, but keeps it in the same code object allowing optimization.

…erators

* Moves the `GET_ITER` instruction into the generator function preamble.
  This means the the iterable is converted into an iterator during generator
  creation, as documented, but keeps it in the same code object allowing
  optimization.
J2085isa

This comment was marked as spam.

J2085isa

This comment was marked as spam.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the code was changed so much since I worked with it, that I can no longer make qualified review. I can understand particular changes, but I cannot catch if something was missed. The original idea looks reasonably.

BTW, what happens when __iter__() raises StopIteration?

Is similar change needed for asynchronous generators?

@markshannon
Copy link
Member Author

markshannon commented Jan 9, 2026

BTW, what happens when __iter__() raises StopIteration?

The exception is raised before the generator is created and the traceback shows the iterable as the location of the exception.

@markshannon
Copy link
Member Author

Is similar change needed for asynchronous generators?

I don't think asynchronous generators were ever changed, so they still have the old behavior from 3.13 and earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants