10000 bpo-42064: Optimise `sqlite3` state access, part 1 by erlend-aasland · Pull Request #27273 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42064: Optimise sqlite3 state access, part 1 #27273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into sqlite-ac-defining-class
Sync with main after GH-27156.
  • Loading branch information
Erlend E. Aasland committed Jul 27, 2021
commit dfbe9891a06615476f4db16876899d44598743f8
23 changes: 7 additions & 16 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self);

static PyObject *
new_statement_cache(pysqlite_state *state, pysqlite_Connection *self,
int maxsize)
new_statement_cache(pysqlite_Connection *self, int maxsize)
{
PyObject *args[] = { PyLong_FromLong(maxsize), };
if (args[0] == NULL) {
return NULL;
}
pysqlite_state *state = pysqlite_get_state(NULL);
PyObject *inner = PyObject_Vectorcall(state->lru_cache, args, 1, NULL);
Py_DECREF(args[0]);
if (inner == NULL) {
Expand Down Expand Up @@ -150,9 +150,7 @@ pysqlite_connection_init_impl(pysqlite_Connection *self,
}
Py_DECREF(isolation_level);

pysqlite_state *state = pysqlite_get_state(NULL);
self->statement_cache = new_statement_cache(state, self,
cached_statements);
self->statement_cache = new_statement_cache(self, cached_statements);
if (self->statement_cache == NULL) {
return -1;
}
Expand All @@ -179,11 +177,7 @@ pysqlite_connection_init_impl(pysqlite_Connection *self,
self->function_pinboard_progress_handler = NULL;
self->function_pinboard_authorizer_cb = NULL;

Py_XSETREF(self->collations, PyDict_New());
if (!self->collations) {
return -1;
}

pysqlite_state *state = pysqlite_get_state(NULL);
self->Warning = state->Warning;
self->Error = state->Error;
self->InterfaceError = state->InterfaceError;
Expand Down Expand Up @@ -321,25 +315,22 @@ int pysqlite_connection_register_cursor(pysqlite_Connection* connection, PyObjec
/*[clinic input]
_sqlite3.Connection.cursor as pysqlite_connection_cursor

cls: defining_class
/
factory: object = NULL

Return a cursor for the connection.
[clinic start generated code]*/

static PyObject *
pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyTypeObject *cls,
PyObject *factory)
/*[clinic end generated code: output=c48c9335315ba58d input=c19d77941a005430]*/
pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory)
/*[clinic end generated code: output=562432a9e6af2aa1 input=4127345aa091b650]*/
{
PyObject* cursor;

if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}

pysqlite_state *state = pysqlite_get_state_by_cls(cls);
pysqlite_state *state = pysqlite_get_state(NULL);
if (factory == NULL) {
factory = (PyObject *)state->CursorType;
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0