[Patches] [ python-Patches-1268314 ] Cache lines in StreamReader.readlines

SourceForge.net noreply at sourceforge.net
Sun Sep 18 10:46:14 CEST 2005


Patches item #1268314, was opened at 2005-08-24 16:13
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1268314&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Martin v. Löwis (loewis)
Assigned to: Nobody/Anonymous (nobody)
Summary: Cache lines in StreamReader.readlines

Initial Comment:
Currently, the splitlines result is discarded, and only
the first line is used. Then, when another line is
requested, the rest string is split again.

With this patch, the splitlines result is preserved if
it has more than two lines, and subsequent .readline
calls get their results from self.linebuffer.
Data is either in self.linebuffer or self.charbuffer;
read() converts the linebuffer back to a charbuffer in
case somebody mixes .read and .readline calls.

On a file with 104 lines (103 of them being "pass") and
542 bytes, the number of _IsLinebreak calls went down
from 6770 to 550

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2005-09-18 10:46

Message:
Logged In: YES 
user_id=21627

Yes, I just committed it as


codecs.py 1.49
NEWS 1.1369
codecs.py 1.35.2.11
NEWS 1.1193.2.101


----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2005-09-02 20:55

Message:
Logged In: YES 
user_id=89016

Is there any change that this patch gets into 2.4.2?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1268314&group_id=5470


More information about the Patches mailing list