survey: is shelve broken? should it be fixed?

Alex Martelli aleax at aleax.it
Tue May 7 18:30:42 EDT 2002


Bjorn Pettersen wrote:

>> From: Alex Martelli [mailto:aleax at aleax.it]
>> 
>> On Tuesday 07 May 2002 21:28, Bjorn Pettersen wrote:
>>> [snip, must work with nested objects]
>> 
>> That's what I see using my patch (corrected for a bug after I
>> posted it to sf):
> 
> Ok, I looked at the patch. Looks pretty straight forward. The only thing
> that remains is to rename the smart argument to something more
> descriptive (my personal favorite is 'autoUpdate'), and setting the
> default equal to False instead of 0 <wink>.

There are also other defects to fix.  One is in __setitem__ (where, in the 
patch, I put the wrong value in the cache!), but that's easy to fix.  The
performance (and correctness, when the shelf file is read-only) of writing
back all the data that was read is more of a problem.  The correctness
part is easy to fix.  The performance isn't.  In some cases, it might be
faster to keep around the original picked string and only write it back if
changed; it might be faster if some (several...) values could be diagnosed
as immutable and the whole mechanism bypassed.

In other words, the totally straightforward approach may well not be the
best implementation of this functionality, if shelves' performance (and
memory consumption) can be important (and they well may be).  But it
seems to me that deciding whether the functionality itself is desired, and
maybe also how precisely to present it to the programmer, has precedence
over finding the best implementation.  It was basically to try to determine
the first point that I posted this survey, and so far it would appear to me 
that the consensus is mildly favorable (despite the rather unfavorable 
reception this group often gives any non-backwards-compatible change).


Alex




More information about the Python-list mailing list