diff -r 0fadf332f0d4 Lib/_compression.py --- a/Lib/_compression.py Fri Jun 05 21:03:52 2015 -0500 +++ b/Lib/_compression.py Sat Jun 06 17:13:30 2015 +0300 @@ -60,6 +60,11 @@ class DecompressReader(io.RawIOBase): self._decompressor = None return super().close() + @property + def closed(self): + # This is polled for every operation; default implementation too slow + return self._decompressor is None + def seekable(self): return self._fp.seekable() diff -r 0fadf332f0d4 Lib/bz2.py --- a/Lib/bz2.py Fri Jun 05 21:03:52 2015 -0500 +++ b/Lib/bz2.py Sat Jun 06 17:13:30 2015 +0300 @@ -232,6 +232,12 @@ class BZ2File(_compression.BaseStream): self._check_can_read() return self._buffer.readlines(size) + def __iter__(self): + # Shortcut to bypass the readline() method above + with self._lock: + self._check_can_read() + return iter(self._buffer) + def write(self, data): """Write a byte string to the file. diff -r 0fadf332f0d4 Lib/gzip.py --- a/Lib/gzip.py Fri Jun 05 21:03:52 2015 -0500 +++ b/Lib/gzip.py Sat Jun 06 17:13:30 2015 +0300 @@ -371,6 +371,11 @@ class GzipFile(_compression.BaseStream): self._check_not_closed() return self._buffer.readline(size) + def __iter__(self): + # Shortcut to bypass the readline() method above + self._check_not_closed() + return iter(self._buffer) + class _GzipReader(_compression.DecompressReader): def __init__(self, fp): diff -r 0fadf332f0d4 Lib/lzma.py --- a/Lib/lzma.py Fri Jun 05 21:03:52 2015 -0500 +++ b/Lib/lzma.py Sat Jun 06 17:13:30 2015 +0300 @@ -219,6 +219,11 @@ class LZMAFile(_compression.BaseStream): self._check_can_read() return self._buffer.readline(size) + def __iter__(self): + # Shortcut to bypass the readline() method above + self._check_can_read() + return iter(self._buffer) + def write(self, data): """Write a bytes object to the file.