On Monday, November 20, 2017 at 1:55:26 PM UTC-5, Chris Angelico wrote:
> But what you have is the strangeness of non-transitive equality, which
> is likely to cause problems.

But this is exactly how Python's built-in dict and OrderedDict behave:

>>> od = OrderedDict([(1, 0), (2, 0), (3, 0)])
>>> od2 = OrderedDict([(3, 0), (2, 0), (1, 0)])
>>> ud = dict(od)
>>> od == ud
True
>>> od2 == ud
True
>>> od == od2
False


Given that, it would seem wrong for our MyOrderedColl.__eq__ to not behave 
similarly.

Or are you suggesting that OrderedDict.__eq__ should not have been implemented 
this way in the first place?


> So the question is: are you willing to
> accept the bizarre behaviour of non-transitive equality?

Forget what I'm personally willing to do :)
The question here actually is to tease out what Python's existing design is 
telling us to do.

If it helps, substitute "frozenset" for "MyColl" and "FrozenOrderedSet" for 
"MyOrderedColl". How would you implement their __eq__ methods? What would be 
the correct design for our hypothetical frozen(ordered)set library? What would 
be more useful, intuitive, and usable for our users?

Thanks very much for the good examples and for helping me clarify the question!
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to