[Python-Dev] Buffer protocol for io.BytesIO? (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Thu Sep 2 23:22:31 CEST 2010
- Previous message: [Python-Dev] Buffer protocol for io.BytesIO?
- Next message: [Python-Dev] Buffer protocol for io.BytesIO?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 object 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 explicit version.
I think getbuffer() also parallels getvalue() quite well.
Call it +1 for explicit and -0 for implicit.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Buffer protocol for io.BytesIO?
- Next message: [Python-Dev] Buffer protocol for io.BytesIO?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]