Sequential compression and decompression is done using the classes
BZ2Compressor and BZ2Decompressor.
Create a new compressor object. This object may be used to compress
data sequentially. If you want to compress data in one shot, use the
compress() function instead. The compresslevel parameter,
if given, must be a number between
9; the default
Provide more data to the compressor object. It will return chunks of compressed
data whenever possible. When you've finished providing data to compress, call
the flush() method to finish the compression process, and return what
is left in internal buffers.
Finish the compression process and return what is left in internal buffers. You
must not use the compressor object after calling this method.
Create a new decompressor object. This object may be used to decompress
data sequentially. If you want to decompress data in one shot, use the
decompress() function instead.
Provide more data to the decompressor object. It will return chunks of
decompressed data whenever possible. If you try to decompress data after the
end of stream is found, EOFError will be raised. If any data was
found after the end of stream, it'll be ignored and saved in
See About this document... for information on suggesting changes.