[New-bugs-announce] [issue19051] Unify buffered readers

Serhiy Storchaka report at bugs.python.org
Thu Sep 19 16:22:09 CEST 2013


New submission from Serhiy Storchaka:

There are some classes in gzip, bz2, lzma, and zipfile modules which implement buffered reader interface. They read chunks of data from underlied file object, decompress it, save in internal buffer, and provide common methods to read from this buffer. Maintaining of duplicated code is cumbersome and error prone. Proposed preliminary patch moves common code into new private class _io2._BufferedReaderMixin. If the proposition will be accepted in general, I'm going to write C version and move it into the io module. Perhaps even then merge it with io.BufferedIOBase.

The idea is that all buffered reading functions (read(), read1(), readline(), peek(), etc) can be expressed in the term of one function which returns raw unbuffered data. Subclasses need define only one such function and will got all buffered reader interface. In case of mentioned above classes this functions reads and decompresses a chunk of data from underlied file. The HTTPResponse class perhaps will benefit too (issue19009).

----------
components: IO, Library (Lib)
files: buffered_reader.diff
keywords: patch
messages: 198075
nosy: alanmcintyre, benjamin.peterson, nadeem.vawda, pitrou, serhiy.storchaka, stutzbach
priority: normal
severity: normal
stage: patch review
status: open
title: Unify buffered readers
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31815/buffered_reader.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19051>
_______________________________________


More information about the New-bugs-announce mailing list