bz2file is a Python library for writing and reading bzip2-compressed files.
It contains a drop-in replacement for the standard library's bz2.BZ2File class, including features from the latest development version of CPython that are not available in older releases.
bz2file is compatible with Python 2.6, 2.7, and 3.0 through 3.3.
To install bz2file, run:
pip install bz2file
The BZ2File class in this module provides the same features and interface as the bz2.BZ2File class in the current development version of CPython, documented here.
Here are some key features of "bz2file":
- Supports multi-stream files.
- Can read from/write to any file-like object.
- Added methods: peek(), read1(), readinto(), fileno(), readable(), writable(), seekable().
- Added the open() function.
- Improved performance when reading in small chunks.
- Removed the fileobj argument to BZ2File(). To wrap an existing file object, pass it as the first argument (filename).