iterating over lines in a file

David Bolen db3l at fitlinxx.com
Fri Jul 21 18:58:44 EDT 2000


cjc26 at nospam.cornell.edu (Cliff Crawford) writes:

> That doesn't seem to be true--readlines() reads the whole file whether
> you specify a size argument or not.  For example:

You might want to try a larger sample - readlines() is documented that
the size value is a hint - it might be rounded up to some internal
buffer size, which I could easily imagine as being a few K.

At least on Windows, with Python 1.5.2, it appears to work in
multiples of about 8K.  That is, size values are rounded up to the
next multiple of 8K, and the total size of information returned will
be somewhat shy of that multiple depending on line length since it
only returns full lines.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list