Skip to content

Dicts with different entry order are equal except inside records #10049

Description

@ageron

The following Dicts are equal despite the fact that their entries are not in the same order. That's perfect.
However, when they're inside a record, the records are not equal.

» Dict.from_list([("Bob", 3.1), ("John", 4.2)]) == Dict.from_list([("John", 4.2), ("Bob", 3.1)])
True
» {owes: Dict.from_list([("Bob", 3.1), ("John", 4.2)])} == {owes: Dict.from_list([("John", 4.2), ("Bob", 3.1)])}
False

Edit: the example is probably easier to read like this:

» d1 = Dict.from_list([("Bob", 3.1), ("John", 4.2)])
assigned `d1`
» d2 = Dict.from_list([("John", 4.2), ("Bob", 3.1)])
assigned `d2`
» d1 == d2
True
» {owes: d1} == {owes: d2}
False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions