You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that for historical purposes, OrderedDict.__repr__ displays key-value pairs in the format of [(key, value), ...], since the {key: value, ...} representation did not respect the ordering that OrderedDict needs. However, this was only in the past and it has become a while since dictionaries have become ordered, so I was wondering if changing the OrderedDict.__repr__ to display OrderedDict({key: value, ...}) instead would be fine. The main rationale is that this is syntactically cleaner to read, often I have found the other representation to be a lot more clunky. Other than potentially breaking things like doc-tests, I don't see much issue with this. The only potential ambiguity that I see is the fact that one might not be immediately sure that the dictionary is ordered, but the fact that it is wrapped by OrderedDict(...) would probably dispel any doubts.
Activity
rhettinger commentedon Feb 4, 2023
I agree that the proposed new
__repr__would be an improvement.pythongh-101446: Change `repr` of `collections.OrderedDict`
gh-101446: Change `repr` of `collections.OrderedDict` (#101661)
Remove test code that does not exercise anything in pybind11, but bre…
Remove test code that does not exercise anything in pybind11, but bre…
rwgk commentedon Mar 9, 2023
Currently this change is mentioned only in the 3.12 Changelog but not under the top-level What’s New In Python 3.12 page.
@Yhg1s suggested that it should be mentioned in What’s New, too. Should I file a separate bug for this, or is this comment sufficient as a reminder?