-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-32360: Replace OrderedDict with dict in inspect.py module #5000
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
Lib/inspect.py
Outdated
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.
Should be: dict
(Docs don’t use English capitalization rules for code references like class names)
|
@merwok please take a look. |
|
@rhettinger ping. |
Lib/inspect.py
Outdated
| params = OrderedDict(((param.name, param) | ||
| for param in parameters)) | ||
| params = dict(((param.name, param) | ||
| for param in parameters)) |
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.
Minor: needless extra set of parens here.
params = dict((param.name, param) for param in parameters)
# or simply:
params = {param.name: param for param in parameters}| @@ -0,0 +1 @@ | |||
| Remove references of OrderedDict in the module `inspect` | |||
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.
IMO «reference» is vague and «import» would be clearer here.
Lib/inspect.py
Outdated
| import builtins | ||
| from operator import attrgetter | ||
| from collections import namedtuple, OrderedDict | ||
| from collections import namedtuple |
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.
If inspect needs to import collections anyway, I don’t think there is much value in removing OrderedDict.
Also replacing params.move_to_end(p) by params[p] = params.pop(p) without even a comment makes the code a bit worse to read.
I would be -1 on this PR.
(I thought I already left this comment? Are there duplicate PRs?)
|
@merwok Done. |
|
I did not mean to ask to remove one line in your patch (the import OrderedDict, which in your latest version is an unused import). I meant that the whole PR seems in the end not needed, since we end up importing collections anyway, and using OrderedDict makes for clearer code. |
https://bugs.python.org/issue32360