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 aleax
Recipients
Date 2002-05-07.08:13:04
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
shelve has highly surprising behavior wrt modifiable
values:
    s = shelve.open('she.dat','c')
    s['ciao'] = range(3)
    s['ciao'].append(4)   # doesn't "TAKE"!

Explaining to beginners that s['ciao'] is returning a
temporary object and the modification is done on the
temporary thus "silently ignored" is hard indeed.  It
also makes shelve far less convenient than it could 
be (whenever modifiable values must be shelved).

Having s keep track of all values it has returned may
perhaps break some existing program (due to extra 
memory consumption and/or to lack of "implicit 
copy"/"snapshot" behavior) so I've made the 'caching' 
change optional and by default off.  However it's now 
at least possible to obtain nonsurprising behavior:
    s = shelve.open('she.dat','c',smart=1)
    s['ciao'] = range(3)
    s['ciao'].append(4)   # no surprises any more

I suspect the 'smart=1' should be made the default, 
but, if we at least put it in now, then perhaps we 
can migrate to having it as the default very slowly 
and gradually.


Alex
History
Date User Action Args
2007-08-23 15:13:06adminlinkissue553171 messages
2007-08-23 15:13:06admincreate