[Python-Dev] "streams" vs "buffers"
solipsis at pitrou.net
Tue May 24 12:06:01 CEST 2011
On Tue, 24 May 2011 10:03:22 +0200
"M.-A. Lemburg" <mal at egenix.com> wrote:
> StreamReader and StreamWriters are implemented by the codecs,
> they are part of the API that each codec has to provide in order
> to register in the Python codecs system. Their purpose is
> to provide a stateful interface and work efficiently and
> directly on streams rather than buffers.
I think you are trying to make a conceptual distinction which doesn't
exist in practice. Your OS uses buffers to represent "streams" to you.
Also, how come StreamReader has internal members named "bytebuffer",
"charbuffer" and "linebuffer"?
There certainly seems to be some (non-trivial) amount of buffering
going on there, and probably quite slow and inefficient since it's pure
Python (TextIOWrapper is written in C).
More information about the Python-Dev