https://pantsbuild.org/ logo
#development
Title
# development
f

fast-nail-55400

10/28/2021, 2:53 AM
I assume
FrozenDict
always returns its elements in the same order when running
repr
on it?
Untitled.txt
I can make the unit test pass by swapping the order in which elements are inserted.
I’d expect behavior more like
FrozenOrderedSet
where insertion order does not matter.
Am I making an unwarranted assumption about
FrozenDict
?
(but the equality test should have returned
True
regardless of the order in which I constructed the data structure in question)
h

happy-kitchen-89482

10/28/2021, 3:27 AM
python dicts are always iterated in insertion order, as of 3.7: https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/
f

fast-nail-55400

10/28/2021, 3:38 AM
but they still compare equally even with different insertion orders:
Copy code
>>> {"a": 0, "b": 1} == {"b": 1, "a": 0}
True
whereas `FrozenDict`s do not
h

happy-kitchen-89482

10/28/2021, 3:42 AM
because we compare item tuples
I wonder why we do that
we could just do
self._data _==_ other._data
I would have thought
And it sounds like that would be more correct