Skip to content

Commit

Permalink
Remove note from docs about 3.8 and deterministic, closes #646
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Nov 23, 2024
1 parent c544f75 commit 04107d3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions docs/python-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2711,16 +2711,14 @@ By default, the name of the Python function will be used as the name of the SQL
print(db.execute('select rev("hello")').fetchone()[0])
Python 3.8 added the ability to register `deterministic SQLite functions <https://sqlite.org/deterministic.html>`__, allowing you to indicate that a function will return the exact same result for any given inputs and hence allowing SQLite to apply some performance optimizations. You can mark a function as deterministic using ``deterministic=True``, like this:
If a function will return the exact same result for any given inputs you can register it as a `deterministic SQLite function <https://sqlite.org/deterministic.html>`__ allowing SQLite to apply some performance optimizations:
.. code-block:: python
@db.register_function(deterministic=True)
def reverse_string(s):
return "".join(reversed(list(s)))
If you run this on a version of Python prior to 3.8 your code will still work, but the ``deterministic=True`` parameter will be ignored.
By default registering a function with the same name and number of arguments will have no effect - the ``Database`` instance keeps track of functions that have already been registered and skips registering them if ``@db.register_function`` is called a second time.
If you want to deliberately replace the registered function with a new implementation, use the ``replace=True`` argument:
Expand Down

0 comments on commit 04107d3

Please sign in to comment.