what happens when the file begin read is too big for all lines to be read with "readlines()"

bonono at gmail.com bonono at gmail.com
Sun Nov 20 05:56:31 EST 2005


Xiao Jianfeng wrote:
>   I have compared the two methods,
>   (1). "for x in fh:"
>   (2). read all the file into memory firstly.
>
>   I have tested the two methods on two files, one is 80M and the second
> one is 815M.
>   The first method gained a speedup of about 40% for the first file, and
> a speedup
>   of about 25% for the second file.
>
>   Sorry for my bad English, and I hope I haven't made people confused.

So is the problem solved ?

Putting buffering implementation aside, (1) is the way to go as it runs
through content only once.




More information about the Python-list mailing list