Author vstinner
Recipients nikratio, pitrou, serhiy.storchaka, vstinner
Date 2014-03-26.10:43:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1395830594.98.0.638444524541.issue21057@psf.upfronthosting.co.za>
In-reply-to
Content
> class MyByteStream(BytesIO):
>    def read1(self, len_):
>        return memoryview(super().read(len_))
> bs = MyByteStream(b'some data in ascii\n')

I guess that you are trying to implement a zero-copy I/O. The problem is that BytesIO does copy data. Example:

>>> data=b'abcdef'
>>> x=io.BytesIO(data)
>>> x.read() is  data
False

Before trying to avoid copies in the "buffered" layer, something should be done for the "raw" layer (BytesIO in this case).
History
Date User Action Args
2014-03-26 10:43:15vstinnersetrecipients: + vstinner, pitrou, nikratio, serhiy.storchaka
2014-03-26 10:43:14vstinnersetmessageid: <1395830594.98.0.638444524541.issue21057@psf.upfronthosting.co.za>
2014-03-26 10:43:14vstinnerlinkissue21057 messages
2014-03-26 10:43:14vstinnercreate