Reputation: 149
Still very new to use this python module, zstd 0.8.1. I did a test run on the following,
import zstd
cctx = zstd.ZstdCompressor()
zstd_data = cctx.compress(b'aaaaa')
len(zstd_data)
Out[34]: 14 #this is my output
However when i did,
cobj = cctx.compressobj()
zstd_data = cobj.compress(b'aaaaa')
len(zstd_data)
Out[39]: 0 #why the length is 0?
What is my mistakes?
Upvotes: 1
Views: 638
Reputation: 68
I know this has been a while, but figured I'd answer for anybody that sees this page on Google.
It looks like you're using the python-zstandard
library (https://github.com/indygreg/python-zstandard/issues). It is important to note that in the examples, the last line for the ZstdCompressor object demos use zstd_data = cobj.flush()
. After you add that line, it should work.
Or, if you prefer the simple API:
cctx = zstd.ZstdCompressor()
compressed = cctx.compress(b'data to compress')
Your second example did not include the flush()
step, which is required for compressobj()
Upvotes: 2