A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-March/098680.html below:

[Python-Dev] Mixing float and Decimal -- thread reboot

[Python-Dev] Mixing float and Decimal -- thread rebootRaymond Hettinger raymond.hettinger at gmail.com
Mon Mar 22 17:39:23 CET 2010
On Mar 22, 2010, at 2:23 AM, Mark Dickinson wrote:
> Note that comparisons are a separate issue:  those always need to be
> done exactly (at least for equality, and once you're doing it for
> equality it makes sense to make the other comaprisons exact as well),
> else the rule that x == y implies hash(x) == hash(y) would become
> untenable.  Again, this is the pattern that already exists for
> int<->float and Fraction<->float interactions: comparisons are exact,
> but arithmetic operations involve a lossy conversion.

My instinct says that we're asking for trouble if comparisons have
different coercion rules than arithmetic operations.

That would suggest that we follow the chain of lossless conversions:

   Fraction + float --> Fraction
   Fraction + decimal --> Fraction
   Decimal + float --> Decimal

That way, arithmetic coercions match comparison coercions.
We preserve get Mark's fast, clean new universal hash function.
The equality/hash homomorphism is preserved.
And a decimal context is not needed for any of the coercions
(it is needed for the addition between two decimals once coercion
has happened, but that is completely normal for Decimal so there
are no surprises). 


Raymond


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4