Against PEP 240

Konrad Hinsen hinsen at
Wed May 30 05:31:08 EDT 2001

"Alex Martelli" <aleaxit at> writes:

> Having 7.35 MEAN 7.35 rather than 7.3499999999999996 is
> an issue of another conceptual order of magnitude, except to
> people who have already been "brainwashed" by experience.

In spite of years of experience with floats, I guess I haven't been
brainwashed yet, I completely agree that a default arithmetic
compatible with common sense is a Good Thing. But I also worry about
compatibility with existing code, of which there is a lot by now.
Whatever number system is chosen, I'd like to make sure that

0) There will be enough automatic conversion to make existing
   C modules using floats work without changes.
1) Scripts that used to run in seconds don't take days.
2) Scripts that used to run in 1 MB of RAM don't require 1 GB.

I have never used rational numbers in calculations, but I do have used
gmpy quite a lot recently for high-precision floating point
computations, and the CPU time overhead is enormous. One of my scripts
now takes five days (with 100 bits) rather than two hours with
standard floats.

There is another more general problem with adding more number types to
Python, namely that the current type coercion mechanism makes it very
difficult to avoid bad surprises. Making sure that a+b is the same as
b+a for any combination of number types a and b is not at all trivial.
Konrad Hinsen                            | E-Mail: hinsen at
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-
Rue Charles Sadron                       | Fax:  +33-
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais

More information about the Python-list mailing list