On Wed, Mar 4, 2020 at 11:23 AM Mark Dickinson firstname.lastname@example.org wrote:
So Decimal is totally orderable to exactly the same extent that float is. (Though the behaviour with NaNs is a little more extreme, since comparisons involving sNaNs will raise rather than return False.) I'd argue that on a practicality-beats-purity basis, it wouldn't be unreasonable to register both `Decimal` and `float` as implementing `TotalOrdering` (or whatever the ABC ends up being called).
I do not disagree on the practicality-beats-purity point. But the "failure" modes are different between Decimal and float.
Technically, Decimal objects themselves are total ordered, but an expression as simple as "+x" creates a different decimal object that depends on context... and I can very easily see folks tripping on that with expected order properties. Floats a total ordered *if you ignore a bunch of them* (the NaNs, which are easy to arrive at by a variety of operations on other floats).
That said, I still haven't actually seen a real use case where we need TotalOrdered as an ABC. I love mathematical concepts as much as the next person, but what are we actually trying to get in our programs?