mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-46874: Speed up sqlite3 user-defined aggregate 'step' method (GH-31604)
This commit is contained in:
parent
751c9ed801
commit
88567a9970
4 changed files with 13 additions and 6 deletions
|
@ -734,11 +734,11 @@ step_callback(sqlite3_context *context, int argc, sqlite3_value **params)
|
|||
PyObject** aggregate_instance;
|
||||
PyObject* stepmethod = NULL;
|
||||
|
||||
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
|
||||
callback_context *ctx = (callback_context *)sqlite3_user_data(context);
|
||||
assert(ctx != NULL);
|
||||
|
||||
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
|
||||
if (*aggregate_instance == NULL) {
|
||||
callback_context *ctx = (callback_context *)sqlite3_user_data(context);
|
||||
assert(ctx != NULL);
|
||||
*aggregate_instance = PyObject_CallNoArgs(ctx->callable);
|
||||
if (!*aggregate_instance) {
|
||||
set_sqlite_error(context,
|
||||
|
@ -747,8 +747,10 @@ step_callback(sqlite3_context *context, int argc, sqlite3_value **params)
|
|||
}
|
||||
}
|
||||
|
||||
stepmethod = PyObject_GetAttrString(*aggregate_instance, "step");
|
||||
stepmethod = PyObject_GetAttr(*aggregate_instance, ctx->state->str_step);
|
||||
if (!stepmethod) {
|
||||
set_sqlite_error(context,
|
||||
"user-defined aggregate's 'step' method not defined");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue