Lazy file.readlines()?

greg andruk meowing at banet.net
Tue Sep 21 03:22:42 EDT 1999


Darrell <news at dorb.com> wrote:

[Thanks for the patch to make Windows happy, BTW.]

> Ran the test.py and enabled the whole file test as well.
> Looks like readline() is a smoker, but read() needs help.

Right, because you end up with two copies of the file in memory if you
use a single read to get the whole file; that's gonna hurt if your
machine is low on RAM.  For whole-file slurping, use the native file
objects which handle that case very efficiently.




More information about the Python-list mailing list