[Python-Dev] decimal.py: == and != comparisons involving NaNs
Mark Dickinson
dickinsm at gmail.com
Mon Nov 9 13:40:06 CET 2009
On Mon, Nov 9, 2009 at 12:21 PM, Stefan Krah <stefan-usenet at bytereef.org> wrote:
> I see the point, but Decimal("NaN") does not hash:
>
>>>> hash(Decimal("NaN"))
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python2.7/decimal.py", line 937, in __hash__
> raise TypeError('Cannot hash a NaN value.')
> TypeError: Cannot hash a NaN value.
I think that may represent an excess of caution. float nans do hash quite
happily, and I can't see a good reason for preventing Decimal nans from
having a hash.
Mark
More information about the Python-Dev
mailing list