Looking under Python's hood: Will we find a high performance or clunky engine?

Rick Johnson rantingrickjohnson at gmail.com
Sun Jan 22 10:50:59 EST 2012

What does Python do when presented with this code?

py> [line.strip('\n') for line in f.readlines()]

If Python reads all the file lines first and THEN iterates AGAIN to do
the strip; we are driving a Fred flintstone mobile. If however Python
strips each line of the lines passed into readlines in one fell swoop,
we made the correct choice.

Which is it Pythonistas? Which is it?

More information about the Python-list mailing list