[Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Mar 21 22:47:53 CET 2010


Nick Coghlan wrote:

> That's fine - binary floats *are* surprising. That's why Decimal exists
> in the first place.

This argument could equally well be used the other way --
someone using Decimal is doing so precisely because they
*don't* want to be surprised, in which case they would
probably prefer to get an exception.

The fundamental problem here is that there are two possible
reasons for a mixed float-decimal operation:

1) The user is thinking in terms of floats and has
happened to get a Decimal mixed in somehow.

2) The user is thinking in terms of Decimals and has
happened to get a float mixed in somehow.

There is no way of distinguishing between these
automatically.

-- 
Greg


More information about the Python-Dev mailing list