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.

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

Reply via email to