Decompression with zlib

E

Emma Li

Hello,

I'm trying to do compression/decompression of stuff with zlib, and I
just don't get it...
Here is an example. I assume that dec should be "a", but it isn't. dec
turns out to be an empty string, and I don't understand why...

===================
import zlib
compressor = zlib.compressobj(6) # level
decompressor = zlib.decompressobj() # wbits

cmpr = compressor.compress("a")
print "compressed", len(cmpr)
dec = decompressor.decompress(cmpr)
print "decompressed", len(dec)

# unconsumed tail and unused data
print "decompressor.unconsumed_tail", decompressor.unconsumed_tail
##print "decompressor.unused_data", decompressor.unused_data

dec += decompressor.flush()
print "after flushing", len(dec)
===================

Any help is appreciated.
Emma
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top