Steven D'Aprano wrote: > On Wed, 24 Mar 2010 08:51:36 pm Mark Dickinson wrote: >>> I don't see how it can be so. Aren't all of those entries garbage? >>> To compute a histogram of results for computations on a series of >>> cases would you not have to test each result for NaN-hood, then >>> hash on a proxy such as the string "Nan"? > > Not necessarily -- you could merely ignore any key which is a NaN, or > you could pass each key through this first: > > def intern_nan(x, nan=float('nan')): > if math.isnan(x): return nan > return x > > thus ensuring that all NaN keys were the same NaN.
Interning NaN certainly seems like it should be sufficient to eliminate the set/dict membership weirdness. That is, make it so that the first two lines of the following return True, while the latter two lines continue to return False: >>> float("nan") is float("nan") False >>> dec("nan") is dec("nan") False >>> float("nan") == float("nan") False >>> dec("nan") == dec("nan") False Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia --------------------------------------------------------------- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com