Skip to content

Conversation

@srinivasreddy
Copy link
Contributor

@srinivasreddy srinivasreddy commented Dec 23, 2017

@srinivasreddy srinivasreddy changed the title bpo:32360: Replace OrderedDict with dict in inspect.py module bpo-32360: Replace OrderedDict with dict in inspect.py module Dec 23, 2017
Lib/inspect.py Outdated
Copy link
Member

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 merwok requested a review from rhettinger December 23, 2017 23:01
@srinivasreddy
Copy link
Contributor Author

@merwok please take a look.

@srinivasreddy
Copy link
Contributor Author

@rhettinger ping.

Lib/inspect.py Outdated
params = OrderedDict(((param.name, param)
for param in parameters))
params = dict(((param.name, param)
for param in parameters))
Copy link
Member

@merwok merwok Jan 24, 2018

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`
Copy link
Member

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
Copy link
Member

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?)

@srinivasreddy
Copy link
Contributor Author

@merwok Done.

@merwok
Copy link
Member

merwok commented Jan 24, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants