[New-bugs-announce] [issue37119] Equality on dict.values() are inconsistent between 2 and 3

林自均 report at bugs.python.org
Sat Jun 1 00:07:01 EDT 2019


New submission from 林自均 <johnlinp at gmail.com>:

When I create 2 different dicts with the same literal, their dict.values() are equal in python2 but not equal in python3.

Here is an example in python2:

    $ python2
    Python 2.7.16 (default, Mar  4 2019, 09:02:22)
    [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> a = {'hello': 'world'}
    >>> b = {'hello': 'world'}
    >>> a.values() == b.values()
    True
    >>> a.keys() == b.keys()
    True

However, the dict.values() are not equal in python3:

    $ python3
    Python 3.7.2 (default, Feb 12 2019, 08:16:38)
    [Clang 10.0.0 (clang-1000.11.45.5)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> a = {'hello': 'world'}
    >>> b = {'hello': 'world'}
    >>> a.values() == b.values()
    False
    >>> a.keys() == b.keys()
    True

Is this a bug? Or is this behavior specified somewhere in the documentation? Thanks.

Note: it's inspired by this StackOverflow question: https://stackoverflow.com/questions/56403613/questions-about-python-dictionary-equality

----------
components: Library (Lib)
messages: 344145
nosy: johnlinp
priority: normal
severity: normal
status: open
title: Equality on dict.values() are inconsistent between 2 and 3
type: behavior
versions: Python 3.7

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


More information about the New-bugs-announce mailing list