shelve vs pickle

kosh at aesaeion.com kosh at aesaeion.com
Sat Sep 15 02:35:36 EDT 2001


On Fri, 14 Sep 2001 hungjunglu at yahoo.com wrote:

> Hi,
>
<snipped for brevity>
> So, I still don't see any benefit from shelve. I can only see that to
> do things safely I would use:
>
What you might want to consider is using the ZODB. It is the object
database that backs zope but it can be used seperately from it easily. It
would give you transactions on your objects, rollbacks, version locking
etc. Overall I seems better then either shelve or pickle are by default.
Overall the ZODB is pretty lightweight and seems to run pretty fast.
Overall I see the ZODB as largely replacing what shelve does.

> (1) a transactional database, or
>
> (2) pickle or xml my Python objects in small units, so that I can
> safely access them. ("safely accessing" means the standard procedure
> of keeping a backup copy before overriding the file, and use file
> renaming schemes to minimize the time of possible data inconsistency
> if the program crashes unexpectly, for instance, due power failure.)
>
> And I just don't see when to use shelve. If I have 1 million items to
> store, I wouldn't use shelve: I'd use transactional database. If I
> have 100 items to save, I wouldn't use shelve: I just use pickle.
>
> There is a small range of applicability of shelve: in situations
> where you: (1) have many items, (2) need to modify many things, but
> in a transactional fashion, typically spending 5 minutes to an hour
> in the process. (3) Don't mind losing the changes if the transaction
> is not completed. I guess you can use shelve for report logging, for
> non-critical web session data, etc.
>
> regards,
>
> Hung Jung
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list