python-zstandard icon indicating copy to clipboard operation
python-zstandard copied to clipboard

How to compress (or decompress) a large file (100G or more) into one file or multiple files using zstd?

Open WUWUYUI opened this issue 7 years ago • 1 comments

I read readme, I know that simple-api is prone to abuse, as The input and output values must fit in memory, so passing in very large values can result in excessive memory usage. For this reason, one of the streaming based APIs is preferred for larger values.

But I didn't understand how to use the streaming API to compress a large file into one or more files. And what should I do when decompressing?

I hope someone can provide a simple example(use python) to give me a reference. Thanks.

WUWUYUI avatar Sep 05 '19 03:09 WUWUYUI

Have you seen the stream_reader() and stream_writer() interfaces? e.g. https://github.com/indygreg/python-zstandard/blob/d774f7c879c5f2d38fb17674f9d0d706f1af00a1/README.rst#stream-reader-api

The specific example here shows how to compress a large file into chunks, which you can then feed to .write(chunk) on an open file handle.

indygreg avatar Sep 14 '19 03:09 indygreg