Skip to content

OrderedDict dict/list representation #101446

Closed
@SimpleArt

Description

@SimpleArt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions