Commit 71189549 authored by R. David Murray's avatar R. David Murray

Make it clear up front that shelve only records changes

when objects are assigned back to it when writeback is False.
parent 5471a776
...@@ -28,13 +28,15 @@ lots of shared sub-objects. The keys are ordinary strings. ...@@ -28,13 +28,15 @@ lots of shared sub-objects. The keys are ordinary strings.
.. versionchanged:: 2.3 .. versionchanged:: 2.3
The *protocol* parameter was added. The *protocol* parameter was added.
By default, mutations to persistent-dictionary mutable entries are not Because of Python semantics, a shelf cannot know when a mutable
automatically written back. If the optional *writeback* parameter is set to persistent-dictionary entry is modified. By default modified objects are
*True*, all entries accessed are cached in memory, and written back at close written only when assigned to the shelf (see :ref:`shelve-example`). If
time; this can make it handier to mutate mutable entries in the persistent the optional *writeback* parameter is set to *True*, all entries accessed
dictionary, but, if many entries are accessed, it can consume vast amounts of are cached in memory, and written back at close time; this can make it
memory for the cache, and it can make the close operation very slow since all handier to mutate mutable entries in the persistent dictionary, but, if
accessed entries are written back (there is no way to determine which accessed many entries are accessed, it can consume vast amounts of memory for the
cache, and it can make the close operation very slow since all accessed
entries are written back (there is no way to determine which accessed
entries are mutable, nor which ones were actually mutated). entries are mutable, nor which ones were actually mutated).
Shelf objects support all methods supported by dictionaries. This eases the Shelf objects support all methods supported by dictionaries. This eases the
...@@ -125,6 +127,8 @@ Restrictions ...@@ -125,6 +127,8 @@ Restrictions
interpretation as for the :class:`Shelf` class. interpretation as for the :class:`Shelf` class.
.. _shelve-example:
Example Example
------- -------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment