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.

classification
Title: Improve BufferedReader.read1()
Type: performance Stage: resolved
Components: IO, Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: neologix, pitrou, python-dev, sbt
Priority: normal Keywords: patch

Created on 2011-11-13 04:15 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bufioread1.patch pitrou, 2011-11-13 04:15 review
textioread.patch pitrou, 2011-11-13 04:16 review
Messages (4)
msg147549 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-13 04:15
The main current user of BufferedReader.read1() is TextIOWrapper. In this context, read1() is used to signal that we want to bypass binary buffering as much as possible, since TextIOWrapper does its own buffering. The current read1() implementation is therefore suboptimal: it copies data around, and limits the number of bytes that you're allowed to get in one call (even if the raw stream would satisfy more).

Attached patch improves read1() in this respect. Also, a separate modification of TextIOWrapper is needed to take advantage of it, which I will attach in another patch.
msg147740 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-16 00:02
New changeset 27bf3d0b8e5f by Antoine Pitrou in branch 'default':
Issue #13393: BufferedReader.read1() now asks the full requested size to
http://hg.python.org/cpython/rev/27bf3d0b8e5f
msg147924 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-18 23:44
New changeset 76d414cc3e38 by Antoine Pitrou in branch 'default':
Issue #13393: In TextIOWrapper.read(n), try to read `n` characters as
http://hg.python.org/cpython/rev/76d414cc3e38
msg147925 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-18 23:58
I've committed a slightly modified patch. Not a huge improvement, but makes sense nevertheless (and it's really short).
History
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57602
2013-07-24 22:06:01pitroulinkissue18524 superseder
2011-11-18 23:58:10pitrousetstatus: open -> closed
resolution: fixed
messages: + msg147925

stage: patch review -> resolved
2011-11-18 23:44:01python-devsetmessages: + msg147924
2011-11-16 00:02:38python-devsetnosy: + python-dev
messages: + msg147740
2011-11-14 23:02:08pitrousetnosy: + neologix, sbt
2011-11-13 04:16:11pitrousetfiles: + textioread.patch
2011-11-13 04:15:01pitroucreate