cpython (3.3): Issue #16304: Further performance improvements for BZ2File.
http://hg.python.org/cpython/rev/4258248a44c7 changeset: 79349:4258248a44c7 branch: 3.3 parent: 79347:51175f1e67fd user: Nadeem Vawda <nadeem.vawda@gmail.com> date: Sun Sep 30 23:58:01 2012 +0200 summary: Issue #16304: Further performance improvements for BZ2File. Optimizations suggested by Serhiy Storchaka. files: Lib/bz2.py | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Lib/bz2.py b/Lib/bz2.py --- a/Lib/bz2.py +++ b/Lib/bz2.py @@ -159,15 +159,21 @@ raise ValueError("I/O operation on closed file") def _check_can_read(self): - if not self.readable(): + if self.closed: + raise ValueError("I/O operation on closed file") + if self._mode not in (_MODE_READ, _MODE_READ_EOF): raise io.UnsupportedOperation("File not open for reading") def _check_can_write(self): - if not self.writable(): + if self.closed: + raise ValueError("I/O operation on closed file") + if self._mode != _MODE_WRITE: raise io.UnsupportedOperation("File not open for writing") def _check_can_seek(self): - if not self.readable(): + if self.closed: + raise ValueError("I/O operation on closed file") + if self._mode not in (_MODE_READ, _MODE_READ_EOF): raise io.UnsupportedOperation("Seeking is only supported " "on files open for reading") if not self._fp.seekable(): -- Repository URL: http://hg.python.org/cpython
participants (1)
-
nadeem.vawda