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

Xiao Jianfeng fdu.xiaojf at gmail.com
Sun Nov 20 06:04:40 EST 2005


bonono at gmail.com wrote:

>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 ?
>  
>
  Yes, thank you.

>Putting buffering implementation aside, (1) is the way to go as it runs
>through content only once.
>
>  
>
  I think so :-)



  Regards,

  xiaojf




More information about the Python-list mailing list