-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-32856: Optimize the assignment idiom in comprehensions. #16814
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
bpo-32856: Optimize the assignment idiom in comprehensions. #16814
Conversation
Now `for y in [expr]` in comprehensions is so fast as a simple assignment `y = expr`.
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.
I don't have an opinion on the general feature, so just a few comments.
Doc/whatsnew/3.9.rst
Outdated
@@ -227,6 +227,17 @@ signals to a process using a file descriptor instead of a pid. (:issue:`38712`) | |||
Optimizations | |||
============= | |||
|
|||
* Optimized the idiom for assignment a temporary variable in comprehensions. | |||
Now ``for y in [expr]`` in comprehensions is so fast as a simple assignment |
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.
"as fast as" (also in news file)
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.
Done. Thank you.
LGTM |
Now
for y in [expr]
in comprehensions is so fast as a simple assignmenty = expr
.Unlike to the
:=
operator this idiom does not leak a variable to the outer scope.https://bugs.python.org/issue32856