preallocate list

rbt rbt at athop1.ath.vt.edu
Wed Apr 13 09:00:57 EDT 2005


Jim wrote:

> If I have a file with a floating point number on each line, what is the 
> best way of reading them into a list (or other ordered structure)?
> 
> I was iterating with readline and appending to a list but it is taking 
> ages.

Perhaps you should use readlines (notice the s) instead of readline.



More information about the Python-list mailing list