[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-03-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I would not add such "optimization", but it is up to Berker to keep or remove it. Please create a PR for review. -- ___ Python tracker

[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-03-11 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: $ python -m pyperf compare_to -G main.json patched.json Faster (1): - bind: 63.6 us +- 1.2 us -> 61.8 us +- 0.9 us: 1.03x faster $ git diff --shortstat master 1 file changed, 41 insertions(+), 74 deletions(-) -- keywords: +patch Added file:

[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-21 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: > I am not sure that the difference is significant enough to justify the > optimization. I would guess it's negligible. I did some quick timeit tests, but the results were pretty much equal, so I guess I'd have to use a more precise benchmark

[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PyLong_Check is two memory reads, bits operation, and comparison with 0. And one non-inlined function call when limited API is used. PyLong_CheckExact is only one memory read and comparison. I am not sure that the difference is significant enough to

[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-19 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland 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

[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is a kind of optimization. We first perform few fast checks for exact types, and then slower subclass checks. I do not know whether this optimization is worth, but it was written so, and there is nothing wrong in it. -- nosy: +serhiy.storchaka

[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-19 Thread Erlend Egeberg Aasland
New submission from Erlend Egeberg Aasland : The type checks at the start of pysqlite_statement_bind_parameter() are redundant: We first check for exact types (*_CheckExact()), and then we check again for exact or subtyped versions (*_Check()). (Adding to the redundantness: the result of