[Python-ideas] Disallow orderring comparison to NaN

Mark Dickinson dickinsm at gmail.com
Sat Apr 30 10:23:01 CEST 2011

On Fri, Apr 29, 2011 at 10:30 PM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> The choices made for float operations are more ad-hoc: DivisionByZero
> is always trapped:
> [...]

Roughly, the current situation is that math module operations try to
consistently follow IEEE 754 exceptions:  an IEEE 754 overflow is
converted to an OverflowError, while invalid-operation or
divide-by-zero signals produce a Python ValueError.

Basic arithmetic is another story:  ** behaves more-or-less like the
math module operations, but the arithmetic operations mainly produce
nans or infinities, except that division by zero is trapped.

IMO, the ideal (ignoring backwards compatibility) would be to have
OverflowError / ZeroDivisionError / ValueError produced wherever
IEEE754 says that overflow / divide-by-zero / invalid-operation should
be signaled.


More information about the Python-ideas mailing list