◐ Shell
clean mode source ↗

Message 395643 - Python tracker

This change makes life harder for people trying to get sane behavior with sets for float-, complex- and tuple-objects containing NaNs. With "sane" meaning, that 

set([nan, nan, nan]) => {nan}

Until now, one has only to override the equal-comparison for these types but now also hash-function needs to be overriden (which is more complicated e.g. for tuple).

----------------------------------------------------------------

On a more abstract level: there are multiple possible equivalence relations. 

The one used right now for floats is Py_EQ and results in float("nan)!=float("nan") due to IEEE 754.

In hash-set/dict we would like to use an equivalence relation for which all NaNs would be in the same equivalence class. Maybe a new comparator is called for (like PY_EQ_FOR_HASH_COLLECTION), which would yield float("nan") equivalent to float("nan") and which should be used in hash-set/dict?