Re: [Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

Marco Sulla mail.python.org at marco.sulla.e4ward.com
Thu Mar 5 17:30:31 EST 2020


I think that implementing TotallyOrderable and PartiallyOrderable is a
good idea. But is it useful?
I mean, I don't know how much people needs really to order sets. Maybe
some mathematician. But they can simply use Sage:
http://doc.sagemath.org/html/en/reference/categories/sage/categories/posets.html

The real problem is NaN. If NaN would not exists, floats will be
perfectly total orderable.
Yes, IEEE 754-2019 defines a total order: -NaN is a number minor that
-Infinity, and +NaN is a number greater than +Infinity. And a NaN is
greater than another NaN if its payload is greater.

But IEEE 754 says also that the division by +0 should return
+Infinity, and by -0 -Infinity.

On the contrary, Python decided to not adhere to IEEE 754 in this case
and do a very wise choice: raise an exception.

The question is: why Python does not do the same for operations that
now return NaN?

Raising a NanError seems to me the only way to eliminate the NaN
problem. Indeed NaN was created for languages like C, that does not
support exceptions.


More information about the Python-list mailing list