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 erlendaasland
Recipients berker.peksag, erlendaasland, serhiy.storchaka
Date 2021-02-19.19:59:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1613764777.96.0.0989371084815.issue43267@roundup.psfhosted.org>
In-reply-to
Content
> It is a kind of optimization.

PyLong_Check is very fast (only one comparison, AFAICS), so there is no gain in first doing PyLong_CheckExact and then PyLong_Check. Ditto for unicode.

PyFloat_Check is the most expensive check, but it comes before both PyUnicode_Check and PyObject_CheckBuffer (both a lot faster), so that's AFAICS the opposite of an optimisation. Correct me if I'm wrong.

If we want to optimise it we should do PyLong_Check, PyUnicode_Check, PyObject_CheckBuffer, and then PyFloat_Check, no?

> there is nothing wrong in it.

True. I'll argue that my suggestion will improve readability and maintainability, which should be worth considering.
History
Date User Action Args
2021-02-19 19:59:37erlendaaslandsetrecipients: + erlendaasland, berker.peksag, serhiy.storchaka
2021-02-19 19:59:37erlendaaslandsetmessageid: <1613764777.96.0.0989371084815.issue43267@roundup.psfhosted.org>
2021-02-19 19:59:37erlendaaslandlinkissue43267 messages
2021-02-19 19:59:37erlendaaslandcreate