C Module's '1.#INF' changes to 'inf' at Python

Mark Dickinson dickinsm at gmail.com
Sat Jan 9 04:22:29 EST 2010


On Jan 8, 3:36 pm, Robert Kern <robert.k... at gmail.com> wrote:
> On 2010-01-08 07:48 AM, CELEN Erman wrote:
> > My problem is that I’ve noticed a strange behavior in Python while
> > handling FPEs on Windows after switching compilers (msvc8 to msvc9) and
> > I am trying to find out how Python handles INF values to figure out
> > where the problem might be.
> > [...]
>
> Python 2.6 changed the string representations of the special floating point
> values inf and nan. Previously, the string representation was left up to the C
> runtime, so they differed between platforms. Python 2.6 normalized the string
> representation across all platforms. The underlying values are the same. What
> version of Python are you using?

In addition to this, for good or ill Python 2.6 also standardized
exceptional behaviour for the math module functions:  log10(0.0) and
sqrt(-1) used to produce different results across implementations, but
now both should consistently produce ValueError regardless of the
platform.  This is achieved by dealing directly with special cases in
the input before delegating to the relevant libm function; this of
course has an associated performance cost.  There are some notes on
the (intended) current behaviour at the top of the Modules/
mathmodule.c file:

http://svn.python.org/view/*checkout*/python/branches/release26-maint/Modules/mathmodule.c

--
Mark



More information about the Python-list mailing list