[Python-Dev] Buffer protocol for io.BytesIO?
ncoghlan at gmail.com
Thu Sep 2 23:22:31 CEST 2010
On Fri, Sep 3, 2010 at 6:35 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Hello all,
> In issue #5506, I originally proposed that io.BytesIO objects support
> the buffer protocol, to make it possible to access the internal buffer
> without intermediate copies.
> Then it came to me then perhaps it would be too automatic. So I'm
> currently floating between:
> - add implicit buffer protocol support to BytesIO objects
> - add explicit buffer protocol support through the call of a
> getbuffer() method, which would return a small intermediate object
> supporting the buffer protocol on behalf of the original BytesIO
> What do you think would be better?
The latter offers an easy future upgrade path if we decide that
implicit would be better (i.e. change getbuffer() to just return
self). If we go straight to implicit there's no easy way back to the
I think getbuffer() also parallels getvalue() quite well.
Call it +1 for explicit and -0 for implicit.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev