Checking for NaN presence in a container
问题 NaN is handled perfectly when I check for its presence in a list or a set. But I don't understand how. [UPDATE: no it's not; it is reported as present if the identical instance of NaN is found; if only non-identical instances of NaN are found, it is reported as absent.] I thought presence in a list is tested by equality, so I expected NaN to not be found since NaN != NaN. hash(NaN) and hash(0) are both 0. How do dictionaries and sets tell NaN and 0 apart? Is it safe to check for NaN presence