[Python-ideas] isinstance(Decimal(), Real) -> False?

random832 at fastmail.us random832 at fastmail.us
Wed Aug 28 13:24:05 CEST 2013


On Wed, Aug 28, 2013, at 6:30, Vernon D. Cole wrote:
> Darn right it should return False.  Given the principle of least surprise
> (and my prejudices built up over 40 years as a computer programmer) I
> would
> expect that decimal.Decimal data would be stored internally as some form
> of
> decimal data, and would store into a database as such.  It would be
> expected to be in a fixed point format.  Real, on the other hand, I would
> expect to be stored as an IEEE double precision floating point number, or
> something like that.
>   I don't care whether a fixed point decimal number might be defined by a
> mathematician as "real" -- I care whether it can be processed by an FPU,
> and whether it will loose precision in large financial calculations.

That's not what Real means, and it's not, for example, true of Fraction.
The type you're thinking of is called "float", and the fact that Fortran
calls it "real" does not obligate numbers.Real to have the same meaning,
no more than the fact that C uses "float" to refer to single precision
obligates us to use that term. There's a difference between "principle
of least surprise" and arbitrarily importing terminology from an
unrelated language.

Also, Decimal is a floating point format - a _decimal_,
arbitrary-precision, floating point format rather than a binary one.
Fixed point means there's a hard limit to the precision (e.g. can never
represent anything finer than 1/100000) and a hard limit to the range.


More information about the Python-ideas mailing list