STINNER Victor <vstin...@python.org> added the comment:
The following result is a little bit surprising: >>> nan=float("nan"); ([nan]*5).count(nan) 5 >>> nan == nan False But in fact, the optimization doesn't change the value. It was already 5 previously. In fact, PyObject_RichCompareBool() has a fast path if the two object pointers are equal: /* 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; } In short, the optimization is good: thank you ;-) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39425> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com