> On Oct 13, 2015, at 9:16 AM, Random832 <random...@fastmail.com> wrote:
> 
>> ## ----------------
>> ## Decimal has all of the methods specified by the Real abc, but it should
>> ## not be registered as a Real because decimals do not interoperate with
>> ## binary floats (i.e.  Decimal('3.14') + 2.71828 is undefined).  But,
>> ## abstract reals are expected to interoperate (i.e. R1 + R2 should be
>> ## expected to work if R1 and R2 are both Reals).
> 
> Why?

Q.  Why is Python the way it is?
A.   Because Guido said so ;-)

IIRC, the answer is that we were being conservative with possibly unintended 
operations between types with differing precision and with differing notions of 
what numbers could be exactly representable.

We could have (and still could) make the choice to always coerce to decimal 
(every float is exactly representable in decimal).  Further, any decimal float 
or binary float could be losslessly coerced to a Fraction, but that probably 
isn't what you really want most of the time.  I think people who work in 
decimal usually want to stay there and people who work with binary floating 
point want to stay there as well (invisible coercions being more likely to 
cause pain than relieve pain).


Raymond


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to