mirror of
https://github.com/python/cpython.git
synced 2025-10-03 05:35:59 +00:00
gh-93829: In sqlite3, replace Py_BuildValue with faster APIs (#93830)
- In Modules/_sqlite/connection.c, use PyLong_FromLong - In Modules/_sqlite/microprotocols.c, use PyTuple_Pack
This commit is contained in:
parent
cdd3984307
commit
4e9fa71d7e
2 changed files with 3 additions and 4 deletions
|
@ -1582,9 +1582,8 @@ static PyObject* pysqlite_connection_get_total_changes(pysqlite_Connection* self
|
||||||
{
|
{
|
||||||
if (!pysqlite_check_connection(self)) {
|
if (!pysqlite_check_connection(self)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
|
||||||
return Py_BuildValue("i", sqlite3_total_changes(self->db));
|
|
||||||
}
|
}
|
||||||
|
return PyLong_FromLong(sqlite3_total_changes(self->db));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* pysqlite_connection_get_in_transaction(pysqlite_Connection* self, void* unused)
|
static PyObject* pysqlite_connection_get_in_transaction(pysqlite_Connection* self, void* unused)
|
||||||
|
|
|
@ -57,7 +57,7 @@ pysqlite_microprotocols_add(pysqlite_state *state, PyTypeObject *type,
|
||||||
|
|
||||||
assert(type != NULL);
|
assert(type != NULL);
|
||||||
assert(proto != NULL);
|
assert(proto != NULL);
|
||||||
key = Py_BuildValue("(OO)", (PyObject*)type, proto);
|
key = PyTuple_Pack(2, (PyObject *)type, proto);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ pysqlite_microprotocols_adapt(pysqlite_state *state, PyObject *obj,
|
||||||
way to get a quotable object to be its instance */
|
way to get a quotable object to be its instance */
|
||||||
|
|
||||||
/* look for an adapter in the registry */
|
/* look for an adapter in the registry */
|
||||||
key = Py_BuildValue("(OO)", (PyObject*)Py_TYPE(obj), proto);
|
key = PyTuple_Pack(2, (PyObject *)Py_TYPE(obj), proto);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue