This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nikratio
Recipients loewis, nikratio, pitrou, serhiy.storchaka, vstinner
Date 2014-04-12.23:03:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397343823.85.0.872765733747.issue21057@psf.upfronthosting.co.za>
In-reply-to
Content
My usecase is that I have a binary stream class that internally uses memoryviews. I would like to read text data from this stream and thus encapsulate it in a TextIOWrapper. Currently, TextIOWrapper (correctly) expects read() to return bytes and fails if it receives any other bytes-like object. I can change my custom class to internally convert to bytes, but this means that the data is needlessly copied around and affects every other consumer of the class as well.

Changing TextIOWrapper to work with any bytes-like object is (as far as I can see) rather simple. It does not introduce any new branches in the code, and it does not change the behavior for bytes objects at all. It does, however, eliminate unnecessary memcopies for classes that do not internally work with bytes objects. Therefore, I was hoping this patch could be considered for inclusion.

The MyByteStream example that I gave in the first message is useless. I merely included it as the smallest possible code fragment that currently does not work, but would work after the patch in an attempt to illustrate what I meant - but apparently it had the opposite effect.

Thanks for considering!
History
Date User Action Args
2014-04-12 23:03:43nikratiosetrecipients: + nikratio, loewis, pitrou, vstinner, serhiy.storchaka
2014-04-12 23:03:43nikratiosetmessageid: <1397343823.85.0.872765733747.issue21057@psf.upfronthosting.co.za>
2014-04-12 23:03:43nikratiolinkissue21057 messages
2014-04-12 23:03:43nikratiocreate