[issue2531] float compared to decimal is silently incorrect.
Mark Dickinson
report at bugs.python.org
Thu Mar 19 19:01:34 CET 2009
Mark Dickinson <dickinsm at gmail.com> added the comment:
Making float <-> Decimal comparisons return the 'right' answer in 2.x does
look attractive at first sight, but the more I think about it the more it
seems a bad idea. Having the comparisons work in 2.x but not in 3.x seems
especially nasty, and allowing mixed-type comparisons but not mixed-type
arithmetic operations also seems somehow unclean. So -1 from me. (And
no, I don't want to add full float <-> Decimal interaction: the Decimal
module is quite complicated enough as it is.)
Are there many cases where float <-> Decimal comparisons are useful? The
only uses I can think of would also involve a need for mixed-type
arithmetic. In the few cases where it's really needed I don't think it's
a problem to explicitly convert one or the other type.
The current bogus comparison results also suck, but they're just one
aspect of a known Python 2.x gotcha.
Would it be possible to raise a warning for Decimal <-> float comparisons?
Does -3 already do this?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2531>
_______________________________________
More information about the Python-bugs-list
mailing list