GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [sqlite3] lazy creation of result rows · Issue #89139 · python/cpython

[sqlite3] lazy creation of result rows #89139

New issue
Copy link
New issue
Copy link
Closed
Closed
[sqlite3] lazy creation of result rows#89139
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-sqlite3type-featureA feature request or enhancementA feature request or enhancement

Description

@erlend-aasland
erlend-aasland
opened on Aug 22, 2021
Issue body actions
BPO 44976
Nosy @berkerpeksag, @serhiy-storchaka, @pablogsal, @erlend-aasland
PRs
  • bpo-44976: Lazy creation of sqlite3 result rows #27884
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-08-25.10:29:18.621>
    created_at = <Date 2021-08-22.09:06:30.968>
    labels = ['extension-modules', 'type-feature']
    title = '[sqlite3] lazy creation of result rows'
    updated_at = <Date 2021-08-25.10:29:18.620>
    user = 'https://github.com/erlend-aasland'

    bugs.python.org fields:

    activity = <Date 2021-08-25.10:29:18.620>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-08-25.10:29:18.621>
    closer = 'pablogsal'
    components = ['Extension Modules']
    creation = <Date 2021-08-22.09:06:30.968>
    creator = 'erlendaasland'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44976
    keywords = ['patch']
    message_count = 3.0
    messages = ['400062', '400065', '400252']
    nosy_count = 4.0
    nosy_names = ['berker.peksag', 'serhiy.storchaka', 'pablogsal', 'erlendaasland']
    pr_nums = ['27884']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44976'
    versions = []

    Activity

    1. erlend-aasland commented on Aug 22, 2021

      @erlend-aasland
      erlend-aasland
      on Aug 22, 2021
      ContributorAuthor
      More actions

      Currently, we build the first result row in the _pysqlite_query_execute() loop if sqlite3_step() returned SQLITE_ROW. When the user asks for a row (for example, using sqlite3.Cursor.fetchone()), this pre-built row is returned, and the next row is prepared.

      Suggesting to lazily build result rows instead.

      Cons:

      • no result tuples are built unless sqlite3.Cursor.fetch*() is called
      • no need to keep the next result row (tuple) in pysqlite_Cursor; rows are built on demand
      • pysqlite_cursor_iternext() is vastly simplified (50% less lines of code)
      • the main loop in _pysqlite_query_execute() is further simplified

      Cons:

      • code churn

      git diff main --shortstat: 2 files changed, 29 insertions(+), 58 deletions(-)

    2. erlend-aasland
      added
      extension-modulesC modules in the Modules dirC modules in the Modules dir
      type-featureA feature request or enhancementA feature request or enhancement
      on Aug 22, 2021
    3. erlend-aasland commented on Aug 22, 2021

      @erlend-aasland
      erlend-aasland
      on Aug 22, 2021
      ContributorAuthor
      More actions

      Historical note:
      The current behaviour was introduced in pysqlite v2.0.2 (May 21 2005), in order to be able to finalise statements and thus close cursors as soon as possible. However, that effect was cancelled just after a couple of months, by the addition of the LRU cache and the ability to reuse prepared statements.

    4. pablogsal commented on Aug 25, 2021

      @pablogsal
      pablogsal
      on Aug 25, 2021
      Member
      More actions

      New changeset 3df0fc8 by Erlend Egeberg Aasland in branch 'main':
      bpo-44976: Lazy creation of sqlite3 result rows (GH-27884)
      3df0fc8

    5. pablogsal
      closed this as completedon Aug 25, 2021
    6. pablogsal
      closed this as completedon Aug 25, 2021
    7. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    8. erlend-aasland
      added
      topic-sqlite3
      on May 16, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-sqlite3type-featureA feature request or enhancementA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402520 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.