[ANN] xreadlines patch on sourceforge
D-Man
dsh8290 at rit.edu
Tue Dec 19 14:04:06 EST 2000
Cool! I was thinking about such a thing with the "while 1:" thread.
-D
On Tue, Dec 19, 2000 at 03:41:55AM +0000, Jeff Epler wrote:
> I've just uploaded my "xreadlines" patch to Sourceforge. You can
> retrieve it from the Patch Manager, and it is my hope that it will
> be considered for inclusion in Python 2.1.
>
> xreadlines, inspired by xrange, permits a simple 'for' loop to iterate
> over the contents of a file without reading the entire file at once.
>
> xreadlines is both a new extension module, as well as an additional
> method on file objects. It includes an entry for the test suite,
> as well as a modified 'fileinput' module which has a >2x speed
> improvement by using the xreadlines function.
>
> example:
>
> def wc(filename):
> l=w=c=0
> for line in open(filename).xreadlines():
> c=c+len(line)
> w=w+len(line.split())
> l=l+1
> return (l,w,c)
>
>
> Jeff Epler
> jepler at inetnebr.com
> --
> http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list