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.

Author erlendaasland
Recipients erlendaasland
Date 2021-06-06.22:21:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623018092.83.0.126983081124.issue44329@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-06-06 22:21:32erlendaaslandsetrecipients: + erlendaasland
2021-06-06 22:21:32erlendaaslandsetmessageid: <1623018092.83.0.126983081124.issue44329@roundup.psfhosted.org>
2021-06-06 22:21:32erlendaaslandlinkissue44329 messages
2021-06-06 22:21:32erlendaaslandcreate