summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2009-05-12 01:36:57 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2009-05-12 01:36:57 (GMT)
commit71189549148922f8fa7ede38433615e0a94d0462 (patch)
tree4467fc4e5c12cc578519597ed93f939d5f307fac /Doc/library
parent5471a77687f2bbcb845d84859285aadd6a8e76ad (diff)
downloadcpython-71189549148922f8fa7ede38433615e0a94d0462.zip
cpython-71189549148922f8fa7ede38433615e0a94d0462.tar.gz
cpython-71189549148922f8fa7ede38433615e0a94d0462.tar.bz2
Make it clear up front that shelve only records changes
when objects are assigned back to it when writeback is False.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/shelve.rst18
1 files changed, 11 insertions, 7 deletions
diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst
index 8a34dd6..4e18ab1 100644
--- a/Doc/library/shelve.rst
+++ b/Doc/library/shelve.rst
@@ -28,13 +28,15 @@ lots of shared sub-objects. The keys are ordinary strings.
.. versionchanged:: 2.3
The *protocol* parameter was added.
- By default, mutations to persistent-dictionary mutable entries are not
- automatically written back. If the optional *writeback* parameter is set to
- *True*, all entries accessed are cached in memory, and written back at close
- time; this can make it handier to mutate mutable entries in the persistent
- dictionary, but, if 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
+ Because of Python semantics, a shelf cannot know when a mutable
+ persistent-dictionary entry is modified. By default modified objects are
+ written only when assigned to the shelf (see :ref:`shelve-example`). If
+ the optional *writeback* parameter is set to *True*, all entries accessed
+ are cached in memory, and written back at close time; this can make it
+ handier to mutate mutable entries in the persistent dictionary, but, if
+ 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).
Shelf objects support all methods supported by dictionaries. This eases the
@@ -125,6 +127,8 @@ Restrictions
interpretation as for the :class:`Shelf` class.
+.. _shelve-example:
+
Example
-------