shelve in a ZipFile?

Andreas Kostyrka andreas at kostyrka.org
Fri Jul 1 17:40:40 EDT 2005


Am Freitag, den 01.07.2005, 10:53 -0700 schrieb Scott David Daniels:
> Terry Hancock wrote:
> > I only just recently had a look at the shelve module....
> > That would be handy if, for example, I wanted to couple
> > (and compress into the bargain) by putting my two
> > shelf files into a single zip archive.
> 
> You are, however, fooling yourself if you think a shelve
> solution can be made to gracefully interact with a zip-
> compressed version.  In order to zip the shelve data, it
> must all be seen in a pass, so every update would necessarily
> rewrite the entire shelve storage.  much better to extract the
> entire shelve file, operate on it, and re-compress it.
> 
> Even if uncompressed, the zip archive format is not going to
> happily allow you to change the size of any of the "files" it
> stores.

It's even worse: shelve is basically a class that wraps a dictionary. It
provides a dictionary string -> pickable object based on a dictioary
string -> string. bsddb, gdbm etc. probably access files via lowlevel
calls that are not interceptable. 

One way to achieve your goals would be to add compression and/or a key
prefix (which would allow multiple dictionaries or at least key spaces
in one file)

Andreas


> 
> --Scott David Daniels
> Scott.Daniels at Acm.Org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://mail.python.org/pipermail/python-list/attachments/20050701/017f72c7/attachment.sig>


More information about the Python-list mailing list