How is Decimal==float implemented? Is it by calling Decimal(rhs) andOn Sat, Mar 8, 2014 at 2:55 PM, Paul Du Bois <email@example.com> wrote:
> On Fri, Mar 7, 2014 at 6:15 PM, Guido van Rossum <firstname.lastname@example.org> wrote:
>> Or, Decimal(repr(some_float)), which DWIM.
> Because I haven't seen anyone else bring this up, using a non-exact
> conversion breaks the invariant "Decimal(f)==f".
> There are so many pairs of numeric types that break that invariant that it
> might not be a big deal; but in all other cases the invariant is broken
> because it is theoretically impossible.
> from decimal import Decimal
> f = 2.2
then comparing? If so, changing how Decimal(float) works won't break
the invariant, as it'll make the same conversion each time.