如果我有几个带有压缩 zlib 数据的二进制字符串,有没有办法有效地将它们组合成一个压缩字符串而不解压缩所有内容?
我现在必须做的示例:
c1 = zlib.compress("The quick brown fox jumped over the lazy dog. ")
c2 = zlib.compress("We ride at dawn! ")
c = zlib.compress(zlib.decompress(c1)+zlib.decompress(c2)) # Warning: Inefficient!
d1 = zlib.decompress(c1)
d2 = zlib.decompress(c2)
d = zlib.decompress(c)
assert d1+d2 == d # This will pass!
Run Code Online (Sandbox Code Playgroud)
我想要的例子:
c1 = zlib.compress("The quick brown fox jumped over the lazy dog. ")
c2 = zlib.compress("We ride at dawn! ")
c = magic_zlib_add(c1+c2) # Magical method of combining compressed streams
d1 = …Run Code Online (Sandbox Code Playgroud)