Daniel Stutzbach <stutzb...@google.com> added the comment:

Looking at this again, I agree with John.  For BufferedIOBase, read() is 
abstract while readinto() is concrete.  That seems backward, and, indeed, it's 
the opposite of RawIOBase, where readinto() is abstract and read() is concrete.

Unfortunately, this code has shipped, so changing which methods are abstract 
may not be practical.  On the other hand, the documentation doesn't mention 
which methods are abstract versus concrete.

All of that said, we can freely change the C implementation of BufferedReader 
which is a concrete class.  That would allow us to cut out the extra 
allocoations/deallocations, even if we can't clean up the abstract vs concrete 
method issue.  Basically, this would require greatly expanding 
buffered_readinto() in bufferedio.c to use _bufferedreader_raw_read() and 
related functions.

As I think about this more... I'm not sure how much performance there is to 
gain here in practice.  It seems like any time I'd want to use readinto(), it's 
because I want to do my own buffering, in which case why would I use a 
BufferedReader?  I'm thinking that BufferedIOBase only provides a readinto() 
method for completeness, so it can be used as a drop-in replacement for an 
unbuffered file object.

----------

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

Reply via email to