[Python-Dev] Mixing float and Decimal -- thread reboot
Adam Olsen
rhamph at gmail.com
Tue Mar 23 19:07:44 CET 2010
On Tue, Mar 23, 2010 at 12:04, Mark Dickinson <dickinsm at gmail.com> wrote:
> On Tue, Mar 23, 2010 at 5:48 PM, Adam Olsen <rhamph at gmail.com> wrote:
>> a = Decimal('nan')
>> a != a
>>
>> They don't follow the behaviour required for being hashable.
>
> What's this required behaviour? The only rule I'm aware of is that if
> a == b then hash(a) == hash(b). That's not violated here.
>
> Note that containment tests check identity before equality, so there's
> no problem with putting (float) nans in sets or dicts:
>
>>>> x = float('nan')
>>>> s = {x}
>>>> x in s
> True
Ergh, I thought that got changed. Nevermind then.
--
Adam Olsen, aka Rhamphoryncus
More information about the Python-Dev
mailing list