Open zacps opened 3 years ago
Oh, that would be nice to have. I think that some of the compression packages, like zip
, will make this difficult to support.
Anyway, thanks for reporting @zacps! I'll see what I can do about this functionality when I get some time.
With zip I think you could do it by writing each call as an individual file in the zip archive. It's possible to add files to a zip without rewriting anything other than the central directory.
My approach would be to check if the current object is seekable, and if it is and the cursor position is non-zero assume we're in the middle of an archive. At that point read the central directory to find where the start of the next file should be, write it, then write the central directory back in.
At load:
Maybe from an API standpoint, considering that some compression algorithms will support multiple objects and some won't, you could simply add an allow_multiple=True
to be added wherever compression is specified (thus giving it a chance to reject an unsupported compression algorithm/allow_multiple pair).
Pickle is capable of storing multiple objects in the same file as each
dump
is self-contained.Hence the following:
Returns
But with this library:
It returns