Python decompressing gzip chunk-by-chunk

后端 未结 2 1880
粉色の甜心
粉色の甜心 2020-11-29 04:42

I\'ve a memory- and disk-limited environment where I need to decompress the contents of a gzip file sent to me in string-based chunks (over xmlrpc binary transfer). However,

2条回答
  •  甜味超标
    2020-11-29 05:14

    gzip and zlib use slightly different headers.

    See How can I decompress a gzip stream with zlib?

    Try d = zlib.decompressobj(16+zlib.MAX_WBITS).

    And you might try changing your chunk size to a power of 2 (say CHUNKSIZE=1024) for possible performance reasons.

提交回复
热议问题