[Python-ideas] Fwd: Why do equality tests between OrderedDict keys/values views behave not as expected?

Guido van Rossum guido at python.org
Thu Dec 17 16:33:50 EST 2015


No, I was just responding to some speculation earlier in the thread. If
this is already defined we should definitely not change it.

On Thu, Dec 17, 2015 at 12:38 PM, Franklin? Lee <
leewangzhong+python at gmail.com> wrote:

> (Note: This is already the case.
> https://docs.python.org/3/library/collections.html#collections.OrderedDict
> """
> Equality tests between OrderedDict objects are order-sensitive and are
> implemented as list(od1.items())==list(od2.items()). Equality tests
> between OrderedDict objects and other Mapping objects are
> order-insensitive like regular dictionaries. This allows OrderedDict
> objects to be substituted anywhere a regular dictionary is used.
> """
>
> So you're asking whether to deprecate this behavior?)
>
> On Thu, Dec 17, 2015 at 2:55 PM, Guido van Rossum <guido at python.org>
> wrote:
> > So I think that not using the __eq__ method of the keys or values is
> wrong
> > (dicts do use it), but there's a philosophical question: if two
> OrderedDicts
> > have the same key/value pairs in a different order, should they be
> > considered equal or not? (Only when we've answered this can we answer the
> > question about keys/values/items).
> >
> > I'm not a frequent user of OrderedDict, so I don't have a good intuition,
> > unfortunately.
> >
> > --
> > --Guido van Rossum (python.org/~guido)
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151217/7d51760c/attachment.html>


More information about the Python-ideas mailing list