On Fri, Jul 26, 2019, at 00:22, Ivan Pozdeev via Python-Dev wrote: > Since a hash table is an unordered container and keys(), items() and > values() are iterators over it, *I would expect the results of any of > the comparisons to be undefined.*
keys, items, and values are not iterators. They are view objects, and keys and items implement the entire set API (in the same sense that range implements the entire sequence API). Values is the odd one out in that it can contain multiple instances of each object, so it can't really be considered as a set. Items also sometimes contains unhashable types, and some methods simply fail in that case. I suggest that this precedent provides a way forward - implement the entire intuitive "contains the same amount of each value" algorithm [more or less Counter(obj1) == Counter(obj2)], and have this fail naturally, throwing e.g. an exception "TypeError: unhashable type: 'list'" if any of the values are unhashable in the same way that trying to perform certain set operations on an items view does. _______________________________________________ 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/UCW7SGSZPY2TNXYR2W7AB7NKAVTULZVT/