3 ms·
It's because cpython shortcuts through identity: https://github.com/python/cpython/blob/main/Objects/object.c#L724-L731 https://github.com/python/cpython/blob/m
by masklinn 4y ago
It's because cpython shortcuts through identity: https://github.com/python/cpython/blob/main/Objects/object.c#L724-L731 https://github.com/python/cpython/blob/main/Objects/object.c...
/* Quick result when objects are the same.
Guarantees that identity implies equality. */
if (v == w) {
if (op == Py_EQ)
return 1;
else if (op == Py_NE)
return 0;
}
`math.nan` is always itself, and thus this shortcut is taken and the key works.