[Python-ideas] Python Float Update
Terry Reedy
tjreedy at udel.edu
Tue Jun 2 19:29:14 CEST 2015
On 6/2/2015 9:05 AM, Andrew Barnert via Python-ideas wrote:
> OK, so what are the stumbling blocks to adding decimal32/64/128 (or
> just one of the three), either in builtins/stdtypes or in decimal,
> and then adding literals for them?
A compelling rationale. Python exposes the two basic number types used
by the kinds of computers it runs on: integers (extended) and floats
(binary in practice, though the language definition would all a decimal
float machine).
The first killer app for Python was scientific numerical computing. The
first numerical package developed for this exposed the entire gamut of
integer and float types available in C. Numpy is the third numerical
package. (Even so, none of the packages have been distributed with
CPython -- and properly so.)
Numbers pre-wrapped as dates, times, and datetimes with specialized
methods are not essential (Python once managed without) but are
enormously useful in a wide variety of application areas.
Decimals, another class of pre-wrapped numbers, greatly simplify money
calculations, including those that must follow legal or contractual
rules. It is no accident that the decimal specification is a product of
what was once International Business Machines. Contexts and specialized
rounding rules are an essential part of fulfilling the purpose of the
module.
What application area would be opened up by adding a fixed-precision
float? The only thing I have seen presented is making interactive
python act even more* like a generic (decimal) calculator, so that
newbies will find python floats less surprising that those of other
languages. (Of course, a particular decimal## might not exactly any
existing calculator.)
*The int division change solved the biggest discrepancy: 1/10 is not .1
instead of 0. Representation changes improved things also.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list