This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lehmannro
Recipients aleax, jherskovic, lehmannro
Date 2009-09-17.13:09:15
SpamBayes Score 1.3361914e-09
Marked as misclassified No
Message-id <1253192958.72.0.854180767169.issue5754@psf.upfronthosting.co.za>
In-reply-to
Content
I think you're misquoting Python's shelve module documentation in your
first sentence. The documentation says:
"By default modified objects are written only when assigned to the shelf
[...]. If the optional writeback parameter is set to True, all entries
accessed are cached in memory, and written back at close time [...]."

The emphasis should be on the word "only:" it does *always* write to the
database when assigned to the shelf but, iff writeback=True, *also* to
the cache.

Also consider the consequences of *only* caching keys:
(a) __contains__ and has_key have to consult the dict and the cache for
membership tests.
(b) keys and __len__ need to compute a union of both sources.
(c) __delitem__ is no longer guaranteed to fail on the cache if it
failed for the database.

I admit the docs could spell this out more clearly. I attached a patch
ensuring the behaviour I described in a test and updating the docs.

(Note: shelve is no extension module -- it's part of the stdlib. Patch
applies to 3.x as well.)
History
Date User Action Args
2009-09-17 13:09:18lehmannrosetrecipients: + lehmannro, aleax, jherskovic
2009-09-17 13:09:18lehmannrosetmessageid: <1253192958.72.0.854180767169.issue5754@psf.upfronthosting.co.za>
2009-09-17 13:09:17lehmannrolinkissue5754 messages
2009-09-17 13:09:16lehmannrocreate