Erlend Egeberg Aasland <erlend.aasl...@innova.no> added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to