In my opinion, things like float('nan') should be optimized, but apparently they aren't in Python.
>>> NaN = float('nan')
>>> a = [ 1, 2, 3, NaN ]
>>> NaN in a
True
>>> float('nan') in a
False
Does it have any meaning with not optimizing nan like other things?
In my thought, nan is only nan.
As well as this, when you use sorted on these things, they give weird results:
>>> sorted([3, nan, 4, 2, nan, 1])
[3, nan, 1, 2, 4, nan]
>>> 3 > float('nan')
False
>>> 3 < float('nan')
False
The comparison on nan is defined like this, but it doesn't seems 'pythonic' to me. Why doesn't it raise an error?