-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Replace list(map(...)) constructs by list comprehensions #46461
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
Done by replacing the regexp `list\(map\(lambda (\w+): (.*?), (\w+)\)\)` by `[$2 for $1 in $3]`
Use the search regexp `list\(map\(lambda (\w+): (.*?), ([0-9a-z_.\]\[]+)\)\)`
Fixes an argument order confusion in distributed_test.py
💊 CI failures summary and remediationsAs of commit 9c06b80 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 5 times. |
030a249 to
9c06b80
Compare
Codecov Report
@@ Coverage Diff @@
## master #46461 +/- ##
=======================================
Coverage 68.38% 68.38%
=======================================
Files 411 411
Lines 53953 53953
=======================================
Hits 36897 36897
Misses 17056 17056
Continue to review full report at Codecov.
|
💊 CI failures summary and remediationsAs of commit 9c06b80 (more details on the Dr. CI page):
codecov.io: 1 failed
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. |
facebook-github-bot
left a comment
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.
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
2 similar comments
Summary: Follow-up of #46461 with a similar goal Makes them more readable and possibly faster. Care has to be taken because `map` applies the function immediately while `(x for x in xs)` is a generator expression which gets evaluated later. This is a benefit in some cases where it is not required to actually create the list of values in memory (e.g. when passing to `tuple` or `extend` or `join`) Pull Request resolved: #46462 Reviewed By: zou3519 Differential Revision: D24422343 Pulled By: ezyang fbshipit-source-id: 252e33499c92ac0b15238f2df32681dbbda2b237
As discussed in #46392 this makes the code more readable and possibly more performant.
It also fixes a bug detected by this where the argument order of
mapwas confused: Flamefire@030a249#diff-5bb26bd3a23ee3bb540aeadcc0385df2a4e48de39f87ed9ea76b21990738fe98L1537-R1537Fixes #46392