[Python-ideas] Fwd: Why do equality tests between OrderedDict keys/values views behave not as expected?
Guido van Rossum
guido at python.org
Sat Dec 19 00:03:40 EST 2015
On Fri, Dec 18, 2015 at 8:07 PM, Franklin? Lee <
leewangzhong+python at gmail.com> wrote:
> If this were lists, then a lack of transitivity of elements would mean
> a lack of transitivity for lists of those elements. You get what you
> put in.
>
> But since dict views are unordered collections, a lack of transitivity
> for elements would mean INCONSISTENCY: the comparison of two views as
> multisets would depend on the exact order of comparison. Unless you
> are willing to compare everything to everything else in the worst
> case.
>
Honestly, I think it's fine if an operation like == for a collection uses
an algorithm that just assumes the items' comparison is transitive, and if
it isn't, you still get what you put it (i.e. it's still like a sewer :-).
It's the same with sort() -- if the comparison is unreasonable the sort
still terminates, just not with the items in sorted order.
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151218/5ab689ed/attachment-0001.html>
More information about the Python-ideas
mailing list