IEEE special values

Tim Peters tim.one at comcast.net
Sat Aug 16 12:39:58 EDT 2003


[Norbert Nemec]
> is there any simple reason why IEEE special values are so poorly
> supported in python?

They're not supported at all, except by accident.  This is because C89
doesn't support them at all, except by accident, and Python is coded in C.

> Are there any serious efforts to change that?

No.  A little less than once a year someone claims very earnestly that
they're going to try, but nothing has come of that.  Don't underestimate the
difficulty of writing portable C that delivers consistent cross-platform
results in the presence of 754 gimmicks!  Virtually everyone does
underestimate it, so eventually gives up when the problems overwhelm their
initial enthusiasm and wishful hopes for quick victory.

> NaN and Inf are an extremely useful concept for numerical
> calculations and they would mix perfectly with the concepts in NumPy,
> anyhow, the support seems to be absolutely minimal.

Again, there's no support in core Python, except by accident.  Python
more-or-less reflects whatever accidental support the platform C compiler
provides.  For example, on most (but not all) Unix platforms, if x is an
infinity then eval(str(x)) == x.  On other Unix platforms, and on Windows,
eval(str(x)) raises an exception.

> (The ideas in PEP 754 do not really change much: There is little
> use in easy access to those values, if the math functions don't accept
> them as input but break down.)

And fixing that requires that Python supply its own math functions.  Fine by
me, but that's too big a project for my spare time, and nobody so far wants
this enough to pay for it.






More information about the Python-list mailing list