New submission from Erlend E. Aasland <erlend.aasl...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue44165>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to