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.

Author xtreak
Recipients johnlinp, rhettinger, xtreak
Date 2019-06-01.05:33:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1559367227.39.0.549643507695.issue37119@roundup.psfhosted.org>
In-reply-to
Content
https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects

> 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 collections.abc.Set 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()
True
>>> a.viewvalues() == b.viewvalues()
False
>>> a.values() == b.values()
True
History
Date User Action Args
2019-06-01 05:33:47xtreaksetrecipients: + xtreak, rhettinger, johnlinp
2019-06-01 05:33:47xtreaksetmessageid: <1559367227.39.0.549643507695.issue37119@roundup.psfhosted.org>
2019-06-01 05:33:47xtreaklinkissue37119 messages
2019-06-01 05:33:47xtreakcreate