On Thu, Jul 25, 2019 at 10:15:15AM +1200, Greg Ewing wrote: > What I'm getting from this thread is that there are a variety of > possible behaviours for dict values comparison, any of which could > be considered "correct" depending on what the programmer is trying > to do.
Can you elaborate on these varieties of behaviour? Aside from "change nothing" and "raise an exception". Speaking for myself, its taken a few iterations to nail down *precisely* how equality ought to work in detail. But the basic semantics hasn't really changed: two (multi)sets of values are equal if they have the same individual values, regardless of order. values {1, 2, 2, [], "abc", 3} and {2, 1, "abc", 3, [], 2} are equal since each have the same elements and counts: 1 occurs once in both; 2 occurs twice in both; 3 occurs once in both; [] occurs once in both; "abc" occurs once in both. So there's a 1:1 correspondence of elements in one values view to elements in the other. (Ignore the fact that lists are unhashable so cannot be inserted into efficient, hash-based Python sets. I'm talking abstract multisets.) I'll admit it took me a few attempts to get the details right (assuming they are right now...), one of my earliest attempts included a fall back to compare lists which was a bug. If there is any other behaviour[1] that makes sense, I haven't seen anyone suggest it. [1] Again, setting aside the current behaviour inherited from object, and raising an exception. -- Steven _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/36TY6NBE6UG3X7QWWUPMJEBEP57CORIO/