
April 28, 2011
2:01 p.m.
Alexander Belopolsky wrote:
Another spin-off from the "[Python-Dev] PyObject_RichCompareBool identity shortcut" thread:
I would like to discuss another peculiarity of NaNs:
float('nan') < 0 False float('nan') > 0 False
This property in my experience causes much more trouble than nan == nan being false. The problem is that common sorting or binary search algorithms may degenerate into infinite loops in the presence of nans.
I think I would like to see a demonstration of this rather than just take your word for it.
sorted([4, 5, 1, float('nan'), 3, 2]) [1, 2, 3, 4, 5, nan]
-- Steven