Author xtreak
Recipients johnlinp, rhettinger, xtreak
Date 2019-06-01.05:33:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>

> Keys views are set-like since their entries are unique and hashable. If all values are hashable, so that (key, value) pairs are unique and hashable, then the items view is also set-like. (Values views are not treated as set-like since the entries are generally not unique.) For set-like views, all of the operations defined for the abstract base class are available (for example, ==, <, or ^).

In Python 2 keys() and values() return a list where __eq__ is implemented. In Python 3 view objects are returned. This can be seen in Python 2 also using viewkeys and viewvalues where viewvalues() is False. So this is not a bug but I am not sure if docs can be improved to clarify this further.

$ python2
Python 2.7.14 (default, Mar 12 2018, 13:54:56)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = {'a': 1}
>>> b = {'a': 1}
>>> a.viewkeys() == b.viewkeys()
>>> a.viewvalues() == b.viewvalues()
>>> a.values() == b.values()
Date User Action Args
2019-06-01 05:33:47xtreaksetrecipients: + xtreak, rhettinger, johnlinp
2019-06-01 05:33:47xtreaksetmessageid: <>
2019-06-01 05:33:47xtreaklinkissue37119 messages
2019-06-01 05:33:47xtreakcreate