[Python-Dev] Mixing float and Decimal -- thread reboot
v+python at g.nevcal.com
Sat Mar 20 01:13:54 CET 2010
On 3/19/2010 2:50 PM, Guido van Rossum wrote:
> I'd like to reboot this thread.
I'll go along with that idea!
> I've been spinning this topic in my
> head for most of the morning, and I think we should seriously
> reconsider allowing mixed arithmetic involving Decimal, not just mixed
> comparisons. [Quick summary: embed Decimal in the numeric tower but
> add a context flag to disallow implicit mixing of float and Decimal.]
As long as there is a way to avoid implicit mixing of float and Decimal,
or to easily detect (preferably with an exception) the implicit mixing,
then I think that solves the concerns of people trying to write
numerically correct code using Decimal. And if Mark (or someone) can
solve the hashing anomoly problem without huge expense, then it could be
> I tried to find the argumentation against it in PEP 327
Should Aahz be consulted, as some of the objections in PEP 327 are
attributed to him, but he is pretty scarce around here these days?
> Also, this would be a possible road
> towards eventually supporting a language extension where floating
> point literals produce Decimal values instead of binary floats. (A
> possible syntax could be "from __options__ import decimal_float",
> which would work similar to "from __future__ import ..." except it's a
> permanent part of the language rather than a forward compatibility
Nice touch here... rather than being forced to quote Decimal values as
strings and convert from string, or use a tuple to represent the parts,
both of which are warts. Not sure what context would be used, though.
More information about the Python-Dev