[Python-Dev] Not-a-Number (original) (raw)

Mark Dickinson dickinsm at gmail.com
Sat Apr 30 09:02:33 CEST 2011


On Fri, Apr 29, 2011 at 2:18 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

Taking a step back from all this, why does Python allow NaNs to arise from computations at all?

History, I think. There's a c.l.p. message from Tim Peters somewhere saying something along the lines that he'd love to make (e.g.,) 1e300

If it weren't for backwards compatibility, I'd love to see Python raise exceptions instead of producing IEEE special values: IOW, to act as though the divide-by-zero, overflow and invalid_operation FP signals all produce an exception. As a bonus, perhaps there could be a mode that allowed 'nonstop' arithmetic, under which infinities and nans were produced as per IEEE 754:

with math.non_stop_arithmetic():
    ...

But this is python-ideas territory.

Mark



More information about the Python-Dev mailing list