Reducing types

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sun Feb 10 14:19:39 EST 2008


For me Python is useful to write code that gives *correct* results,
allowing me to write it in a short & simple way, with quick debugging
cycles (and for other purposes, like to write dynamic code, to use it
as glue language to use libraries, to create quick GUIs, as scripting
for data munging, etc). When I need more speed I use the D language,
or Psyco, or C, etc.

Python 2.5 has string, unicode, long, int, float, and Decimal types.
Python 3.0 reduces them to string (+ the byte type) int, float, and
Decimal. So why not adopt the Decimal (IEEE 854) as the standard
"float" for Python (if speed is a concern, than a mfloat type may be
introduced, it's a "machine float", it's essentially the "float" of
Python 2.5, operations between a float and a mfloat give a mfloat)? It
can reduce some FP bugs, and avoid those 5.89 + 3.99 =
9.879999999999999 bugs that puzzle newbies, that are okay in a very
fast low-level language like C++, but probably unfit for a high-level
one :-)

Bye,
bearophile



More information about the Python-list mailing list