[New-bugs-announce] [issue37585] Comparing PyDictValues does not give expected results

Kristian Klette report at bugs.python.org
Sat Jul 13 07:58:48 EDT 2019


New submission from Kristian Klette <klette at klette.us>:

As a user, I expect to be able to compare the different parts a `dict`
in the same manner.

Currently, `PyDictValues` does not implement the `dictview_richcompare`, causing the `__eq__` to always return false, even if the values are identical.


```
my_dict = {'foo': 'bar'}
dict_copy = my_dict.copy()
other_dict = {'foo': 'bar', 'bar': 1234}

assert my_dict.keys() == my_dict.keys()
assert my_dict.keys() == dict_copy.keys()
assert my_dict.keys() != other_dict.keys()

assert my_dict.items() == my_dict.items()
assert my_dict.items() == dict_copy.items()
assert my_dict.items() != other_dict.items()

assert my_dict.values() == my_dict.values()
assert my_dict.values() == dict_copy.values()
assert my_dict.values() != other_dict.values()

```

----------
components: Library (Lib)
messages: 347806
nosy: Kristian Klette
priority: normal
severity: normal
status: open
title: Comparing PyDictValues does not give expected results
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37585>
_______________________________________


More information about the New-bugs-announce mailing list