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.
Linked PRs
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 thatOrderedDictneeds. However, this was only in the past and it has become a while since dictionaries have become ordered, so I was wondering if changing theOrderedDict.__repr__to displayOrderedDict({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 byOrderedDict(...)would probably dispel any doubts.Linked PRs
reprofcollections.OrderedDict#101661