shelve in a ZipFile?
hancock at anansispaceworks.com
Sat Jul 2 04:06:24 CEST 2005
On Friday 01 July 2005 12:53 pm, Scott David Daniels wrote:
> 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.
Yeah, I've already decided to just go with the two linked
The only drawback to this is that the user can accidentally
separate the two files, which causes one of them to become
useful (1st shelf relies on named references to objects in the
2nd shelf). I used to have problems like that with IRAF, which
stored image headers and images in two related files with
different file extensions. Once they're two separate units,
you have to consider the cases where they get separated.
OTOH, the 2nd shelf file has independent uses, which don't
depend on the 1st, so in that way, it's desireable for it to
Probably if I was really worried about it, I'd come up with
a more serious solution, but this is a lightweight script, so
I think I'll just stick with shelve for convenience. Actually,
as small as the databases are in this project, I probably
could've just pickled a tuple of dictionaries (or something
similar). But I think shelves will probably do a better job.
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
More information about the Python-list