<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 7, 2014 at 8:16 PM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Sat, Mar 8, 2014 at 3:11 PM, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
>> How is Decimal==float implemented? Is it by calling Decimal(rhs) and<br>
>> then comparing? If so, changing how Decimal(float) works won't break<br>
>> the invariant, as it'll make the same conversion each time.<br>
<br>
> There's a special function to convert the other operand for the purpose of<br>
> comparisons, and it currently uses Decimal.from_float(). I am not (yet :-)<br>
> proposing to change the behavior of that function -- it is and has always<br>
> been the API function that does exact float-to-Decimal conversion.<br>
> Decimal(repr(f)) == f returns False today (for the majority of float values<br>
> anyway) and under my proposal Decimal(f) == f would also return False. I<br>
> don't (yet :-) think that's a deal breaker.<br>
<br>
</div>Maybe not a deal breaker, but certainly another panel on the bikeshed.<br>
It would make good sense to retain that invariant by making the<br>
comparison use repr just like the constructor.<br></blockquote></div><br></div><div class="gmail_extra">Not sure I agree. I find the invariant Decimal(x) == x rather uninteresting. I find the idea that Decimal.__eq__ compares the exact mathematical values very appealing.<br clear="all">
</div><div class="gmail_extra"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)
</div></div>