I assume `FrozenDict` always returns its elements ...
# development
f
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
python dicts are always iterated in insertion order, as of 3.7: https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/
f
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
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