On 23/07/2019 21:59, Kristian Klette wrote:
Hi!
During the sprints after EuroPython, I made an attempt at adding support for
comparing the results from `.values()` of two dicts.
Currently the following works as expected:
```
d = {'a': 1234}
d.keys() == d.keys()
d.items() == d.items()
```
but `d.values() == d.values()` does not return the expected
results. It always returns `False`. The symmetry is a bit off.
In the bug trackers[0] and the Github PR[1], I was asked
to raise the issue on the python-dev mailing list to find
a consensus on what comparing `.values()` should do.
The request was to establish a consensus on a reasonable semantic. I
don't think that can be adequately addressed by such a simple example
and the criterion "works as expected". What is expected of:
>>> x = dict(a=1, b=2)
>>> y = dict(b=2, a=1)
>>> x == y
True
Two superficially reasonable semantics are to compare the list or the
set of the values:
>>> set(x.values()) == set(y.values())
True
>>> list(x.values()) == list(y.values())
False
Terry points out some implementation and definitional problems
(unhashable values) with set demantics. Steven proposes (essentially)
list semantics, but isn't it surprising that equal dictionaries should
not have equal .values()?
Jeff Allen
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/4GKPJHRMV5QKSVZ3T44MG4NOUOUISNST/