-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[mypyc] set(f(x) for x in it) no longer uses list comprehension (#771)
#9707
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
2bf5498 to
0c33ec8
Compare
|
Looks good, would you mind posting the generated code before/after the patch so we can make sure of its usefulness. (You can find the compiled C code in |
|
For the following code Master branch produces This branch produces |
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.
Thanks for the updates! Looks good! The generated code shows we successfully avoid the needless list construction.
I'm only concerned with CPyL8, do we really need an extra set creation here?
cc @JukkaL
|
The second set creation may defeat the purpose of this optimization, since we replace the construction of a list with a construction of a set, and creating a set is slower than creating a list. I think that we need to get rid of the second set creation, unless perhaps some benchmark can show that it doesn't matter. |
set(f(x) for x in it) no longer uses list comprehension (#771)set(f(x) for x in it) no longer uses list comprehension (#771)
Closes mypyc/mypyc#771 and #9707. Changes: * Move code from tranform_set_comprehension to translate_set_comprehension * Fix the unnecessary set creation (#9707 (comment))
|
This PR has been covered by #10261 |
Description
Solves mypyc/mypyc#771
Test Plan
Added statements to the run-sets.test file