Message85971
| Author |
jherskovic |
| Recipients |
jherskovic |
| Date |
2009年04月14日.17:03:21 |
| SpamBayes Score |
4.7932427e-09 |
| Marked as misclassified |
No |
| Message-id |
<1239728605.41.0.419145925815.issue5754@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The shelve module documentation states that "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..."
however the implementation's __setitem__ is the following:
def __setitem__(self, key, value):
if self.writeback:
self.cache[key] = value
f = StringIO()
p = Pickler(f, self._protocol)
p.dump(value)
self.dict[key] = f.getvalue()
which maintains the cache correctly but writes back to the disk on every
operation, violating the writeback documentation. Changing it to
def __setitem__(self, key, value):
if self.writeback:
self.cache[key] = value
else:
f = StringIO()
p = Pickler(f, self._protocol)
p.dump(value)
self.dict[key] = f.getvalue()
seems to match the documentation's intent.
(First report, sorry for any formatting/style issues!) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2009年04月14日 17:03:25 | jherskovic | set | recipients:
+ jherskovic |
| 2009年04月14日 17:03:25 | jherskovic | set | messageid: <1239728605.41.0.419145925815.issue5754@psf.upfronthosting.co.za> |
| 2009年04月14日 17:03:23 | jherskovic | link | issue5754 messages |
| 2009年04月14日 17:03:22 | jherskovic | create |
|