[issue9971] Optimize BufferedReader.readinto

Antoine Pitrou report at bugs.python.org
Sun May 8 17:49:25 CEST 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

> The trade-off of accommodating a small buffer size (by buffering
> behind the scenes anyways) would likely slow the more common cases
> which use a decent buffer size. I am wondering if an effort to
> accommodate both uses would be appropriate. Possibly by not
> double-buffering if readinto(b): len(b) > buffer_size/2 (arbitrary but
> seems feasible), and copying directly as the patch does now.
> Otherwise, fill the buffer up for subsequent reads and copy len(b) to
> user buffer. There is probably a good equilibrium for when it makes
> more/less sense to bypass the internal buffer.

Yes, it sounds reasonable. I think the best thing to do is to experiment
and run some measurements.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9971>
_______________________________________


More information about the Python-bugs-list mailing list