[Patches] [Patch #102915] xreadlines : readlines :: xrange : range

noreply@sourceforge.net noreply@sourceforge.net
Fri, 05 Jan 2001 06:22:27 -0800


Patch #102915 has been updated. 

Project: python
Category: Modules
Status: Open
Submitted by: jepler
Assigned to : gvanrossum
Summary: xreadlines : readlines :: xrange : range

Follow-Ups:

Date: 2001-Jan-05 06:22
By: jepler

Comment:
As requested by Guido, add a docstring and info in Doc/lib

xreadlines-as-method of the builtin file object is retained, but is not
added to any builtin file-like object.

the speedup of the fileinput module is still present and appears to work,
but I note there's no testsuite for the fileinput module.  If there's any
concern about the behavior of my modifications to fileinput, just ignore
those changes.
-------------------------------------------------------

Date: 2001-Jan-04 18:40
By: gvanrossum

Comment:
After timing tests and discussion on python-dev I'm much more inclined to
accept this.  Jeff, would you mind adding docs?  I don't care about adding
an xreadlines method to other file-line objects, since the xreadlines
module can be used directly by those who want to be generic.

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

Date: 2001-Jan-01 09:59
By: gvanrossum

Comment:
Bah.  I don't like this one bit.  More complexity for a little bit of extra
speed.
I'm keeping this open but expect to be closing it soon unless I hear a
really good argument why more speed is really needed in this area.  Down
with code bloat and creeping featurism!

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

Date: 2000-Dec-30 02:33
By: loewis

Comment:
This patch appears to be incomplete. There is no documentation of the
feature, and no other file-like object is touched: StringIO, cStringIO,
gzip, codecs.
-------------------------------------------------------

Date: 2000-Dec-18 19:32
By: jepler

Comment:
This patch implements an object 'xreadlines' in C, as well as a method on
the file object to create one.

xreadlines will let a 'for' loop iterate over the contents of a file
without reading the whole file, yet at a speed almost equal to that of 'for
line in f.readlines()'.  Internally, it uses f.readlines(sizehint).

Includes a test suite and a version of fileinput which uses it (approx. 50%
speedup in fileinput as well).  fileinput is not tested by test suite entry.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=102915&group_id=5470