-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
GH-127682: Only call __iter__
once in generator expressions.
#132351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks @markshannon for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @markshannon, I could not cleanly backport this to
|
Do you need to bump the magic number here? I forgot if compiler-only changes need that. |
I don’t think so, since the bytecode format and behavior is unchanged. |
@@ -123,15 +123,6 @@ | |||
>>> list(g) | |||
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81] | |||
Verify that the outermost for-expression makes an immediate check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a regression.
If this change of behaviour is actually desirable (which may require some further discussion to establish), it should be mentioned in the What's New documentation. |
See #135171 (comment) for a more detailed analysis I'll make a PR for the what's new |
Removes the extra
GET_ITER
instruction emitted when creating a generator expression.This:
__iter__
method to be used in generator expressions, as they were up until 3.12.