[Python-ideas] BufferedIO and detach

Antoine Pitrou solipsis at pitrou.net
Mon Mar 4 11:47:43 CET 2013


Le Mon, 4 Mar 2013 19:12:03 +1000,
Nick Coghlan <ncoghlan at gmail.com> a
écrit :
> On Mon, Mar 4, 2013 at 4:44 PM, Robert Collins
> <robertc at robertcollins.net> wrote:
> > Some variations I can think of...
> >
> > The buffer_only flag I suggested, on read_into, read1, read etc.
> >
> > Have detach return the buffered data as you suggest - that would be
> > incompatible unless we stash it on the raw object somewhere, or do
> > something along those lines.
> >
> > A read0 - analogous to read1, returns data from the buffer, but
> > guarantees no underlying calls.
> >
> > I think exposing the buffer more explicitly is a good principle,
> > independent of whether we change detach or not.
> 
> As Guido noted, you actually have multiple layers of buffering to
> contend with - for a text stream, you may have already decoded
> characters and partially decoded data in the codec's internal buffer,
> in addition to any data in the IO buffer.

I'd prefer if TextIOWrapper was totally unsupported in that context.

Regards

Antoine.





More information about the Python-ideas mailing list