Peter Otten a écrit :
> Bruno Desthuilliers wrote:
> 
>> # You don't need to read the whole file in memory
> 
>> lines1, lines2 = tee(infile)
>> print min(extract_numbers(lines1)), max(extract_numbers(lines2))
> 
> tee() internally maintains a list of items that were seen by
> one but not all of the iterators returned. Therefore after calling min()
> and before calling max() you have a list of one float per line in memory
> which is quite close conceptually to reading the whole file in memory.
> 
> If you want to use memory efficiently, stick with the for-loop.

Indeed - I should have specified that the second version was not 
necesseraly better wrt/ either perfs and/or resources usage. Thanks for 
having made this point clear.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to