Stefan Krah <stefan-usenet <at> bytereef.org> writes:
d = {0:Decimal("NaN")} Decimal("NaN") in d.values() False
So, since non-decimal use cases are limited at best, the equality/inequality operators might as well have the behavior of the other comparison operators, which is safer for the user.
The problem is when searching for /another/ object which hashes the same as Decimal("NaN"). Here is a made-up situation to show you the problem:
class H(object): ... def __hash__(self): return hash(1) ... def __eq__(self, other): raise ValueError ... h = H() d = {h: ""} d[1] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in __eq__ ValueError d[1] = 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in __eq__ ValueError