This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [sqlite3] _pysqlite_connection_begin() optimisations
Type: performance Stage: resolved
Components: Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, erlendaasland, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-05-04 23:41 by erlendaasland, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25908 merged erlendaasland, 2021-05-04 23:44
Messages (2)
msg392967 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-05-04 23:41
The following optimisations can be applied to _pysqlite_connection_begin():

1. Return an int instead of a PyObject pointer

   Per now, we do Py_RETURN_NONE and Py_DECREF(result) if _pysqlite_connection_begin() was successful (normally the case). There's no reason to do this. Let's just it the C way: return -1 on error and 0 if things are ok.


2. Defer error checking till post sqlite3_finalize()

   Any error code returned by sqlite3_step() will also be returned by sqlite3_finalize() for the same statement. From the SQLite docs:
   "If the most recent evaluation of statement S failed, then sqlite3_finalize(S) returns the appropriate error code or extended error code."


3. Move _pysqlite_connection_begin() to Modules/_sqlite/cursor.c

   The single use is in _pysqlite_query_execute() in cursor.c. Moving it makes it possible for the compiler to apply more optimisations. At least so I've heard :)
   (As a side effect, the namespace will be cleaner.)
msg395051 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-06-03 21:24
New changeset 3446516ffa92c98519146253153484291947b273 by Erlend Egeberg Aasland in branch 'main':
bpo-44042: Optimize sqlite3 begin transaction (GH-25908)
https://github.com/python/cpython/commit/3446516ffa92c98519146253153484291947b273
History
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88208
2021-06-03 21:24:34pablogsalsetstatus: open -> closed
nosy: - pablogsal

resolution: fixed
stage: patch review -> resolved
2021-06-03 21:24:29pablogsalsetnosy: + pablogsal
messages: + msg395051
2021-05-04 23:44:57erlendaaslandsetkeywords: + patch
stage: patch review
pull_requests: + pull_request24576
2021-05-04 23:41:24erlendaaslandcreate