[Python-Dev] Rich comparisons

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Sun Mar 21 17:18:21 EST 2004


> 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



More information about the Python-Dev mailing list