◐ Shell
clean mode source ↗

bpo-46541: Replace _Py_IDENTIFIER with _Py_ID in sqlite3 by erlend-aasland · Pull Request #31351 · python/cpython

PTAL. This should result in a small speedup compared to main.

The sqlite3.Connection.cursor() calls are now made directly. Ideally we should do the same with the Cursor.execute* calls, but sqlite3 is inconveniently implemented across multiple files1, so we can't just call the cursor impl methods directly. I changed the scope of _pysqlite_query_execute, so we can at least speed up the Connection.execute() and Connection.executemany() calls. The remaining methods now use interned strings, with the module always keeping a strong ref to __adapt__, __conform__, and upper to speed up adapters/converters, and finalize to speed up user-defined functions. I did the same for executemany; it is probably not used in hot code, but following the same pattern simplified the code a bit.

Footnotes

  1. Consolidating all the Module/_sqlite/*.[ch] files into Module/_sqlite3.[ch] would be very helpful.