[New-bugs-announce] [issue39496] Inelegant loops in Modules/_sqlite/cursor.c

Alex Henrie report at bugs.python.org
Wed Jan 29 22:18:40 EST 2020

New submission from Alex Henrie <alexhenrie24 at gmail.com>:

pysqlite_cursor_fetchall currently has the following bit of code:

    /* just make sure we enter the loop */
    row = (PyObject*)Py_None;

    while (row) {
        row = pysqlite_cursor_iternext(self);
        if (row) {
            PyList_Append(list, row);

This can and should be rewritten as a for loop to avoid the unnecessary initialization to Py_None and the redundant if statement inside the loop.

pysqlite_cursor_fetchmany has the same problem.

components: Library (Lib)
messages: 361006
nosy: alex.henrie
priority: normal
severity: normal
status: open
title: Inelegant loops in Modules/_sqlite/cursor.c
type: performance
versions: Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list