On Wed, Mar 4, 2020 at 11:23 AM Mark Dickinson <dicki...@gmail.com> 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?

-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7NQ6L7ZZSHOHTFQUCMAAYB4TA5NI53QD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to