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

SourceForge.net noreply at sourceforge.net
Wed Aug 24 16:13:50 CEST 2005


Patches item #1268314, was opened at 2005-08-24 16:13
Message generated for change (Tracker Item Submitted) made by Item Submitter
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: Open
Resolution: None
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

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

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