Bob Smith wrote:
To do this efficiently on a large file (dozens or hundreds of megs), you should use the 'sizehint' parameter so as not to use too much memory:
sizehint = 0 mylist = f.readlines(sizehint)
It doesn't make any difference. .readlines reads the entire file into memory at once.
Are you sure, the docs say this:
"f.readlines() returns a list containing all the lines of data in the file. If given an optional parameter sizehint, it reads that many bytes from the file and enough more to complete a line, and returns the lines from that. This is often used to allow efficient reading of a large file by lines, but without having to load the entire file in memory. Only complete lines will be returned."
http://docs.python.org/tut/node9.html -- http://mail.python.org/mailman/listinfo/python-list