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

Michael Poeltl michael.poeltl at univie.ac.at
Sun Jan 22 15:57:06 EST 2012

* Ian Kelly <ian.g.kelly at gmail.com> [2012-01-22 19:29]:
> 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?
I cannot understand why it is so important for you to store
lines out of a textfile in a list without '\n'. 
have you ever considered the *pros* of leaving '\n' ?
> >
> >
> 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.
why there is only one possibility to do so? in a second i found this

and if you don't like python, then stick to ruby. who cares???

Michael Poeltl
Computational Materials Physics      voice: +43-1-4277-51409
Univ. Wien, Sensengasse 8/12         fax:   +43-1-4277-9514 (or 9513) 
A-1090 Wien, AUSTRIA   cmp.mpi.univie.ac.at 
ubuntu-11.10 | vim-7.3 | python-3.2.2 | mutt-1.5.21 | elinks-0.12
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120122/4633b653/attachment-0001.html>

More information about the Python-list mailing list