[Numpy-discussion] RE: Python 2.2 seriously crippled for numerical computation?

Andrew MacIntyre andymac at bullseye.apana.org.au
Sat Mar 2 10:18:22 CST 2002


On 2 Mar 2002, Konrad Hinsen wrote:

> Tim Peters <tim.one at comcast.net> writes:
>
> > > # Python 2.2
> > >
> > > >>> 1e-200**2
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in ?
> > > OverflowError: (34, 'Numerical result out of range')
> >
> > That one is surprising and definitely not intended:  it suggests your
> > platform libm is setting errno to ERANGE for pow(1e-200, 2.0), or that your
> > platform C headers define INFINITY but incorrectly, or that your platform C
> > headers define HUGE_VAL but incorrectly, or that your platform C compiler
> > generates bad code, or optimizes incorrectly, for negating and/or comparing
>
> I just tested and found the same behaviour, on RedHat Linux 7.1
> running on a Pentium machine. Python 2.1, compiled and running on the
> same machine, returns 0. So does the Python 1.5.2 that comes with the
> RedHat installation. Although there might certainly be something wrong
> with the C compiler and/or header files, something has likely changed
> in Python as well in going to 2.2, the only other explanation I see
> would be a compiler optimization bug that didn't have an effect with
> earlier Python releases.

Other examples...

FreeBSD 4.4:
Python 2.1.1 (#1, Sep 13 2001, 18:12:15)
[GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
Type "copyright", "credits" or "license" for more information.
>>> 1e-200**2
0.0
>>> 1e200**2
Inf

Python 2.3a0 (#1, Mar  1 2002, 00:00:52)
[GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> 1e-200**2
0.0
>>> 1e200**2
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: (34, 'Result too large')

Both builds built with "./configure --with-fpectl", although the
optimisation settings for the 2.3a0 (CVS of yesterday) build were tweaked
(2.1.1: "-g -O3"; 2.3a0: "-s -m486 -Os").

My 2.2 OS/2 EMX build (which uses gcc 2.8.1 -O2) produces exactly the same
result as 2.3a0 on FreeBSD.

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  | Snail: PO Box 370
        andymac at pcug.org.au            |        Belconnen  ACT  2616
Web:    http://www.andymac.org/        |        Australia





More information about the Numpy-discussion mailing list