-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143409: Use dict and set comprehensions when possible #143410
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,9 +161,9 @@ | |
| NAME_MAPPING[("multiprocessing", excname)] = ("multiprocessing.context", excname) | ||
|
|
||
| # Same, but for 3.x to 2.x | ||
| REVERSE_IMPORT_MAPPING = dict((v, k) for (k, v) in IMPORT_MAPPING.items()) | ||
| REVERSE_IMPORT_MAPPING = {v: k for (k, v) in IMPORT_MAPPING.items()} | ||
| assert len(REVERSE_IMPORT_MAPPING) == len(IMPORT_MAPPING) | ||
| REVERSE_NAME_MAPPING = dict((v, k) for (k, v) in NAME_MAPPING.items()) | ||
| REVERSE_NAME_MAPPING = {v: k for (k, v) in NAME_MAPPING.items()} | ||
| assert len(REVERSE_NAME_MAPPING) == len(NAME_MAPPING) | ||
|
Comment on lines
-164
to
167
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's necessary. It's just code churn and this is only executed once upon import time. |
||
|
|
||
| # Non-mutual mappings. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -295,8 +295,8 @@ def get_names(self): | |
|
|
||
| def complete_help(self, *args): | ||
| commands = set(self.completenames(*args)) | ||
| topics = set(a[5:] for a in self.get_names() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case I wonder which one would be faster:
Because of all possible changes, I don't think we want to change this. It's just code churn. |
||
| if a.startswith('help_' + args[0])) | ||
| topics = {a[5:] for a in self.get_names() | ||
| if a.startswith('help_' + args[0])} | ||
| return list(commands | topics) | ||
|
|
||
| def do_help(self, arg): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Use dict and set comprehensions when possible |
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 an unrelated change, please revert.