bpo-33463: _asdict --> dict, not OrderedDict#6772
Conversation
Now that dict is tracking insertion order, namedtuple._asdict can be switched to returning a basic dict instead of an OrderedDict. The interface is largely similar, but some minor differences will require a deprecation cycle before making the change.
As per @serhiy-storchaka's suggestion, a warning here is too noisy. The difference between OrderedDict and dict is now negligible.
Added versioning info and fixed the doctest example.
|
I changed the docs to note the change as of Version 3.8. If this is accepted, I'll create separate pull requests to add warnings to the docs of older versions. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Needed a test.
Please add a What's New entry and remove a duplicated news entry, and clarify the reason of reverting the 3.1 change.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
@serhiy-storchaka Were you saying this needs a test for the returned type? There's already a test verifying that cpython/Lib/test/test_collections.py Line 333 in 1b5f9c9 |
|
For testing just add something like: self.assertEqual(list(p._asdict().items()), [('x': 11), ('y': 22)])
Since this change breaks compatibility, it needs to be mentioned in the What's New document, in the "Porting to 3.8" section. |
|
I added a bit to What's New, but I just realized I need to move that to the "Porting to 3.8" section. I'll do that shortly. |
|
Ok, I added a short comment about constructing an OrderedDict if using the |
|
Thanks for the PR. Have applied an alternative version so the issue is taken care of. |
Now that dict is tracking insertion order, namedtuple._asdict can be
switched to returning a basic dict instead of an OrderedDict. The
interface is largely similar, but some minor differences will require a
deprecation cycle before making the change.
https://bugs.python.org/issue33463