]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 72574 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Tue, 12 May 2009 01:42:03 +0000 (01:42 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Tue, 12 May 2009 01:42:03 +0000 (01:42 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r72574 | r.david.murray | 2009-05-11 21:40:16 -0400 (Mon, 11 May 2009) | 10 lines

  Merged revisions 72572 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r72572 | r.david.murray | 2009-05-11 21:36:57 -0400 (Mon, 11 May 2009) | 3 lines

    Make it clear up front that shelve only records changes
    when objects are assigned back to it when writeback is False.
  ........
................

Doc/library/shelve.rst

index a023504a82d4e7afe1a7a76c55d426b95b95220d..9d820012fbe9f61a2b138c9d931e22121869a5a3 100644 (file)
@@ -26,13 +26,15 @@ lots of shared  sub-objects.  The keys are ordinary strings.
    By default, version 3 pickles are used to serialize values.  The version of the
    pickle protocol can be specified with the *protocol* parameter.
 
-   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).
 
 Shelve objects support all methods supported by dictionaries.  This eases the
@@ -119,6 +121,8 @@ Restrictions
    interpretation as for the :class:`Shelf` class.
 
 
+.. _shelve-example:
+
 Example
 -------