| Store | Cart

[Python-Dev] Rich comparisons

From: <tdel...@avaya.com ) (Delaney, Timothy C (Timothy)>
Sun, 21 Mar 2004 17:18:29
> From: Edward Loper> > If we *really* want nan==nan to be false, then it seems like > we have to > say that nan is unhashable.

Hmm - I suppose we could make a subclass of float specifically for NaN, and have that be a singleton. The float constructor could check for a NaN result, and return this singleton.

I'm worried that there might be a slowdown though.

> I'm also disturbed by the fact > that cmp() > has something different to say about their equality:> >      >>> cmp(float('nan'), float('nan'))>      0

Hmm - I guess it should technically throw an exception. However, I'd be happy if it returned -1. Would this affect the stability of sorting?

Tim Delaney

Recent Messages in this Thread
tdel...@avaya.com ) (Delaney, Timothy C (Timothy) Mar 21, 2004 05:18 pm