8000 Tiny optimisation: increase the cache size from 100 to 128 · python/cpython@18c486c · GitHub
[go: up one dir, main page]

Skip to content

Commit 18c486c

Browse files
author
Erlend E. Aasland
committed
Tiny optimisation: increase the cache size from 100 to 128
1 parent f1f023b commit 18c486c

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

Doc/library/sqlite3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line c 8000 hange
@@ -213,7 +213,7 @@ Module functions and constants
213213
The :mod:`sqlite3` module internally uses a statement cache to avoid SQL parsing
214214
overhead. If you want to explicitly set the number of statements that are cached
215215
for the connection, you can set the *cached_statements* parameter. The currently
216-
implemented default is to cache 100 statements.
216+
implemented default is to cache 128 statements.
217217

218218
If *uri* is true, *database* is interpreted as a URI. This allows you
219219
to specify options. For example, to open a database in read-only mode

Doc/whatsnew/3.10.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,10 +1231,10 @@ Add audit events for :func:`~sqlite3.connect/handle`,
12311231
:meth:`~sqlite3.Connection.load_extension`.
12321232
(Contributed by Erlend E. Aasland in :issue:`43762`.)
12331233
1234-
12351234
:mod:`sqlite3` now utilizes :meth:`functools.lru_cache` to implement the
12361235
connection statement cache. The statement cache can be accessed via the new
1237-
method :meth:`sqlite3.Connection.statement_cache`.
1236+
method :meth:`sqlite3.Connection.statement_cache`. As a small optimisation, the
1237+
default statement cache size has been increased from 100 to 128.
12381238
(Contributed by Erlend E. Aasland in :issue:`42862`.)
12391239
12401240
sys

Lib/sqlite3/test/dbapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ def test_statement_cache(self):
207207
info = cache.cache_info()
208208
self.assertEqual(info.hits, 1)
209209
self.assertEqual(info.misses, 1)
210-
self.assertEqual(info.maxsize, 100)
210+
self.assertEqual(info.maxsize, 128)
211211
self.assertEqual(info.currsize, 1)
212212

213213
def test_statement_cache_maxsize(self):
214-
maxsize = 5
214+
maxsize = 8
215215
testsize = maxsize + 1
216216
cx = sqlite.connect(':memory:', cached_statements=maxsize)
217217
for i in range(testsize):
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
:mod:`sqlite3` now utilizes :meth:`functools.lru_cache` to implement the
22
connection statement cache. The statement cache can be accessed via the new
3-
method :meth:`sqlite3.Connection.statement_cache`. Patch by Erlend E.
4-
Aasland.
3+
method :meth:`sqlite3.Connection.statement_cache`. As a small optimisation, the
4+
default statement cache size has been increased from 100 to 128.
5+
Patch by Erlend E. Aasland.

Modules/_sqlite/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
105105
PyObject* isolation_level = NULL;
106106
PyObject* factory = NULL;
107107
int check_same_thread = 1;
108-
int cached_statements = 100;
108+
int cached_statements = 128;
109109
int uri = 0;
110110
double timeout = 5.0;
111111
int rc;

0 commit comments

Comments
 (0)
0