Search code examples
python-3.xzlib

Python 3.7 zlib decompressed size is smaller than compressed


I wrote a small python code, which is supposed to decompress a ~180Mb large binary file. The issue is that it only decompresses around 50Mb. I wonder if anyone has came across similar, weird issue like this before, and found solution for it.

import zlib, sys
text = open('REG_E.rzp','rb').read()
print(sys.getsizeof(text))
# 187424785


decompressed = zlib.decompress(text)
print(sys.getsizeof(decompressed))
# 50001

Additional info: the first decompressed 50Mbytes are correct, and readable in hex editor. So I'm wondering, is there a limit, on how much zlib can decompress at once? I get no error messages, so I'm kinda in the dark with this.


Solution

  • Issue is solved. The archive was composed from multiple compressed files and had to be decompressed file by file.