[issue5863] bz2.BZ2File should accept other file-like objects.

Antoine Pitrou report at bugs.python.org
Wed Jan 26 14:33:07 CET 2011

Antoine Pitrou <pitrou at free.fr> added the comment:

> * The read*() methods are implemented very inefficiently. Since they
> have to deal with the bytes objects returned by
> BZ2Decompressor.decompress(), a large read results in lots of
> allocations that weren't necessary in the C implementation.

It probably depends on the buffer size. Trying to fix this /might/ be
premature optimization.

Also, as with GzipFile one goal should be for BZFile to be wrappable in
a io.BufferedReader, which has its own very fast buffering layer (and
also a fast readline() if you implement peek() in BZFile).

> * Fixed a typo in test_bz2's testReadChunk10() that caused the test to
> pass regardless of whether the data read was correct
> (self.assertEqual(text, text) -> self.assertEqual(text, self.TEXT)).
> This one might be worth committing now, since it isn't dependent on
> the rewrite.

Ah, thank you. Will take a look.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list