[issue44165] [sqlite3] sqlite3_prepare_v2 micro optimisation: pass string size
Erlend E. Aasland
report at bugs.python.org
Tue May 18 03:23:06 EDT 2021
New submission from Erlend E. Aasland <erlend.aasland at innova.no>:
The signature of sqlite3_prepare_v2 is as follows:
int sqlite3_prepare_v2(
sqlite3 *db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
Quoting from the SQLite docs[1]:
"If the caller knows that the supplied string is nul-terminated, then there is a small performance advantage to passing an nByte parameter that is the number of bytes in the input string including the nul-terminator."
sqlite3_prepare_v2 is used five places in the sqlite3 module. We can easily provide the string size in those places.
[1] https://sqlite.org/c3ref/prepare.html
----------
components: Extension Modules
messages: 393856
nosy: berker.peksag, erlendaasland, serhiy.storchaka
priority: low
severity: normal
status: open
title: [sqlite3] sqlite3_prepare_v2 micro optimisation: pass string size
type: performance
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44165>
_______________________________________
More information about the Python-bugs-list
mailing list