[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()
Erlend Egeberg Aasland
report at bugs.python.org
Fri Feb 19 14:59:37 EST 2021
Erlend Egeberg Aasland <erlend.aasland at 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 <report at bugs.python.org>
<https://bugs.python.org/issue43267>
_______________________________________
More information about the Python-bugs-list
mailing list