On Wed, 24 Mar 2010 05:04:37 am Mark Dickinson 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 As usual though, NANs are unintuitive: >>> d = {float('nan'): 1} >>> d[float('nan')] = 2 >>> d {nan: 1, nan: 2} I suspect that's a feature, not a bug. -- Steven D'Aprano
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