This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: dict_values should be comparable with a set
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ThiefMaster, r.david.murray
Priority: normal Keywords:

Created on 2015-01-28 10:59 by ThiefMaster, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg234888 - (view) Author: ThiefMaster (ThiefMaster) Date: 2015-01-28 10:59
>>> d = {'1': '2'}
>>> {'1'} < d.keys()
False
>>> {'1'} < set(d.values())
False
>>> {'1'} < d.values()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: set() < dict_values()


Same for e.g. the `-` operator.

Since dict_keys acts like a real set I think dict_values should do so, too. At least if all the values are hashable.
msg234894 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-01-28 14:42
values cannot be a set, since unlike keys it may contain unhashable objects.  It would be...really strange and contrary to Python's philosophy to have the validity of an operation depend on the specific data values in a structure rather than its type.  Python is a strongly typed language.
History
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67528
2015-01-28 14:42:56r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg234894

resolution: not a bug
stage: resolved
2015-01-28 10:59:47ThiefMastercreate