Issue 5506: io.BytesIO doesn't support the buffer protocol (original) (raw)

Created on 2009-03-18 10:40 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bytesiobuf2.patch pitrou,2010-09-03 17:53
Messages (7)
msg83740 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-03-18 10:40
It may be logical for BytesIO to support the buffer protocol (readable /and/ writable).
msg85504 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-05 14:41
Is this still unimplemented?
msg85507 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-04-05 14:52
Yes. I don't remember which use case I was thinking about when I suggested this, but it may be useful to e.g. write() all the data to a file object without actually making a copy (getvalue() does).
msg115304 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-01 14:48
Thinking about it, I'm not sure this would be a good idea to do this by default. There is an ambiguity where it's not obvious if the buffer would contain the whole data or only the bytes after the current position. I think perhaps an explicit method (getbuffer()?) could be used to export a buffer-compatible object, without copying. Perhaps a memoryview; this would imply defining bf_releasebuffer without bf_getbuffer.
msg115476 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-03 17:49
Here is a patch implementing getbuffer(), together with tests.
msg115479 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-03 17:53
There was an unused "weakreflist" member.
msg115728 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-06 18:50
This was committed in r84562.
History
Date User Action Args
2022-04-11 14:56:46 admin set github: 49756
2010-09-06 18:50:12 pitrou set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2010-09-03 17:53:48 pitrou set nosy: + amaury.forgeotdarc, benjamin.petersoncomponents: + IO
2010-09-03 17:53:33 pitrou set files: - bytesiobuf2.patch
2010-09-03 17:53:24 pitrou set files: + bytesiobuf2.patchmessages: +
2010-09-03 17:49:12 pitrou set files: + bytesiobuf2.patchkeywords: + patchmessages: + stage: needs patch -> patch review
2010-09-01 14:48:06 pitrou set messages: + stage: test needed -> needs patch
2010-08-09 03:55:35 terry.reedy set versions: + Python 3.2, - Python 3.1
2009-04-05 14:52:09 pitrou set messages: +
2009-04-05 14:41:01 georg.brandl set nosy: + georg.brandlmessages: +
2009-03-18 10:40:11 pitrou create