Nikolaus Rath added the comment:

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!

----------
type: behavior -> enhancement
versions:  -Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to