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 — bpo-42862: Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module by erlend-aasland · Pull Request #24203 · python/cpython

bpo-42862: Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module #24203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pablogsal merged 18 commits into python:main from erlend-aasland:sqlite-cache
Jun 3, 2021

Uh oh!

There was an error while loading. Please reload this page.

Merged

bpo-42862: Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module #24203

Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9c24ebc
Use functools.lru_cache iso. _sqlite.Cache/Node
Dec 26, 2020
0a8133a
Update documentation
Jan 12, 2021
7830f3b
Add tests
Jan 12, 2021
5c8e05c
Add NEWS
Jan 12, 2021
d2078bc
Fix tests on Windows
Jan 21, 2021
6c6a422
Tiny optimisation: increase the cache size from 100 to 128
May 2, 2021
2795aca
Move What's New to 3.11
May 14, 2021
05ce0e4
Address review: don't expose cache API
May 19, 2021
839f264
Remove empty line
May 19, 2021
8d1c138
Address review: document Windows test workaround
May 19, 2021
0067cef
Address review: check PyLong_FromLong ret value
May 19, 2021
a95a386
Address review: add global state and add LRU cache func to it
May 19, 2021
9882ebd
Fix rebase
May 25, 2021
150b3e7
Merge branch 'main' into sqlite-cache
May 29, 2021
5a4aacc
Revert test workaround
Jun 2, 2021
d1a233a
Merge branch 'main' into sqlite-cache
Jun 3, 2021
401b057
Improve naming: get_statement => get_statement_from_cache
Jun 3, 2021
dfb47a8
Remove spurious change in connection_dealloc
Jun 3, 2021
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

2 changes: 1 addition & 1 deletion 2 Doc/library/sqlite3.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Module functions and constants
The :mod:`sqlite3` module internally uses a statement cache to avoid SQL parsing
overhead. If you want to explicitly set the number of statements that are cached
for the connection, you can set the *cached_statements* parameter. The currently
implemented default is to cache 100 statements.
implemented default is to cache 128 statements.

If *uri* is true, *database* is interpreted as a URI. This allows you
to specify options. For example, to open a database in read-only mode
Expand Down
11 changes: 11 additions & 0 deletions 11 Lib/sqlite3/test/dbapi.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import sqlite3 as sqlite
import sys

from test.support import gc_collect
from test.support.os_helper import TESTFN, unlink


Expand Down Expand Up @@ -181,6 +182,11 @@ def __fspath__(self):
with sqlite.connect(path) as cx:
cx.execute('create table test(id integer)')

# bpo-42862: addCleanup fails to unlink TESTFN on Windows unless we
# explicitly close the connection and run the GC.
cx.close()
gc_collect()
Comment thread
erlend-aasland marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


def test_open_uri(self):
self.addCleanup(unlink, TESTFN)
with sqlite.connect(TESTFN) as cx:
Expand All @@ -191,6 +197,11 @@ def test_open_uri(self):
with self.assertRaises(sqlite.OperationalError):
cx.execute('insert into test(id) values(1)')

# bpo-42862: addCleanup fails to unlink TESTFN on Windows unless we
# explicitly close the connection and run the GC.
cx.close()
gc_collect()


class CursorTests(unittest.TestCase):
def setUp(self):
Expand Down
7 changes: 7 additions & 0 deletions 7 Lib/sqlite3/test/hooks.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import unittest
import sqlite3 as sqlite

from test.support import gc_collect
from test.support.os_helper import TESTFN, unlink


Expand Down Expand Up @@ -261,6 +262,12 @@ def trace(statement):
cur.execute(queries[1])
self.assertEqual(traced_statements, queries)

# bpo-42862: addCleanup fails to unlink TESTFN on Windows unless we
# explicitly close the connections and run the GC.
con1.close()
con2.close()
gc_collect()
Comment thread
erlend-aasland marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.



def suite():
tests = [
Expand Down
4 changes: 4 additions & 0 deletions 4 Misc/NEWS.d/next/Library/2021-01-13-00-02-44.bpo-42862.Z6ACLN.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:mod:`sqlite3` now utilizes :meth:`functools.lru_cache` to implement the
connection statement cache. As a small optimisation, the default
statement cache size has been increased from 100 to 128.
Patch by Erlend E. Aasland.
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.