[New-bugs-announce] [issue44329] [sqlite3] refactor pysqlite_statement_create
Erlend E. Aasland
report at bugs.python.org
Sun Jun 6 18:21:32 EDT 2021
New submission from Erlend E. Aasland <erlend.aasland at innova.no>:
Currently, pysqlite_statement_create() approx. looks like this:
1. some sanity checks (type, sql lenght, etc.)
2. allocate (PyObject_GC_New)
3. initialise members
4. determine if statement is a DML statement
5. create the statement (sqlite3_prepare_v2)
6. PyObject_GC_Track
7. check statement return value
8. more sanity checking
9. done!
Suggesting to refactor as this:
1. all sanity checks => early exit on failure
2. create the statement and validate return value
3. determine if statement is a DML statement => no need to do this if statement creation failed
4. allocate
5. initialise members
5. return
This will avoid unneeded allocations/GC tracking, it will avoid unneeded statement creation, and it will be more readable/maintainable.
----------
assignee: erlendaasland
components: Extension Modules
messages: 395224
nosy: erlendaasland
priority: low
severity: normal
status: open
title: [sqlite3] refactor pysqlite_statement_create
type: enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44329>
_______________________________________
More information about the New-bugs-announce
mailing list