On Mar 4, 2020, at 01:56, Mark Dickinson
On Wed, Mar 4, 2020 at 9:22 AM Andrew Barnert via Python-ideas
wrote: Is there any commonly used or even imaginable useful type that uses them in weirder ways than set and float (which are both partially ordered) [...]
Nitpick: why do you say "partially ordered" for float? If we take NaNs into account, then the float type is neither partially nor totally ordered, since x <= x is False when x is a NaN.
In math, non-strict orders (<=) are usually considered the more fundamental and useful concept, but in programming it’s the other way around: Python’s sort is based on < rather than <=, and the same is true in C++, Haskell, etc. And < (and IEEE lessThan) is a strict partial order: it’s irreflexive, transitive, and antisymmetric. And it’s properly partial, because of NaN values.
So, how can < be a strict partial order when <= is not a non-strict partial order, even though they’re related in the usual way (x<=y iff x If we don't take NaNs into account (which is probably the way we'd want to go from a practicality standpoint), it's both partially and totally ordered. (To David Mertz's earlier comment, "not a total order when you include nans and infs", infinities don't affect the existence of a total or partial order here; it's only the NaNs that we have to worry about.) You do have to worry about -0 and +0, however, but only very briefly: -0 == 0, not -0 < 0, not 0 < -0, so they aren’t breaking the equivalence or the order. Only NaNs break the equivalence, and therefore the non-strict partial order, and they also turn the strict total order into a strict properly partial order.