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

Ian Kelly ian.g.kelly at gmail.com
Sun Jan 22 13:28:12 EST 2012


On Sun, Jan 22, 2012 at 8:50 AM, Rick Johnson
<rantingrickjohnson at gmail.com>wrote:

>
> 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?
>
>
Two iterations.  And since that is the only possible way to do this, you
are correct, the language is terribly archaic.  I suggest you switch to
Ruby ASAP.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120122/803394d5/attachment-0001.html>


More information about the Python-list mailing list