bpo-42064: Optimise sqlite3 state access, part 1 (GH-27273)

Prepare for module state:

- Add "get state by defining class" and "get state by module def" stubs
- Add AC defining class when needed
- Add state pointer to connection context
- Pass state as argument to utility functions

Automerge-Triggered-By: GH:encukou
This commit is contained in:
Erlend Egeberg Aasland 2021-07-29 11:21:45 +02:00 committed by GitHub
parent 47fd4726a2
commit d542742128
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 103 additions and 66 deletions

View file

@ -71,7 +71,8 @@ pysqlite_microprotocols_add(PyTypeObject *type, PyObject *proto, PyObject *cast)
/* pysqlite_microprotocols_adapt - adapt an object to the built-in protocol */
PyObject *
pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
pysqlite_microprotocols_adapt(pysqlite_state *state, PyObject *obj,
PyObject *proto, PyObject *alt)
{
_Py_IDENTIFIER(__adapt__);
_Py_IDENTIFIER(__conform__);
@ -86,7 +87,6 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
if (!key) {
return NULL;
}
pysqlite_state *state = pysqlite_get_state(NULL);
adapter = PyDict_GetItemWithError(state->psyco_adapters, key);
Py_DECREF(key);
if (adapter) {