This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients corona10, methane, miss-islington, pablogsal, vstinner
Date 2020-01-22.21:43:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579729416.97.0.712573165188.issue39425@roundup.psfhosted.org>
In-reply-to
Content
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 ;-)
History
Date User Action Args
2020-01-22 21:43:37vstinnersetrecipients: + vstinner, methane, corona10, pablogsal, miss-islington
2020-01-22 21:43:36vstinnersetmessageid: <1579729416.97.0.712573165188.issue39425@roundup.psfhosted.org>
2020-01-22 21:43:36vstinnerlinkissue39425 messages
2020-01-22 21:43:36vstinnercreate