Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19241
| Date | 2012-01-22 17:38 -0700 |
|---|---|
| From | Michael Torrie <torriem@gmail.com> |
| Subject | Re: Looking under Python's hood: Will we find a high performance or clunky engine? |
| References | <3c0bb3d0-6b80-44ec-848a-7296d526c047@t8g2000yqg.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4945.1327279145.27778.python-list@python.org> (permalink) |
On 01/22/2012 08:50 AM, Rick Johnson 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?
You're doing it wrong, obviously. I'm actually surprised that an expert
such as yourself would read a file in this way. In any language.
Surely you would iterate over the file object which is the obvious way
to do it.
I guess we'll chalk this up as another python pitfall. Looking forward
to your programming language which will prevent such things while
maintaining the purity and beauty of Python's ideals.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Looking under Python's hood: Will we find a high performance or clunky engine? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-01-22 07:50 -0800
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Heiko Wundram <modelnine@modelnine.org> - 2012-01-22 18:52 +0100
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Robert Kern <robert.kern@gmail.com> - 2012-01-22 18:01 +0000
Re: Looking under Python's hood: Will we find a high performance or clunky engine? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-23 10:56 -0800
Re: Looking under Python's hood: Will we find a high performance or clunky engine? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-23 10:56 -0800
Re: Looking under Python's hood: Will we find a high performance or clunky engine? alex23 <wuwei23@gmail.com> - 2012-01-23 22:44 -0800
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Chris Angelico <rosuav@gmail.com> - 2012-01-24 19:14 +1100
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Michael Torrie <torriem@gmail.com> - 2012-01-22 17:38 -0700
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-01-22 17:04 -0800
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Michael Torrie <torriem@gmail.com> - 2012-01-22 18:32 -0700
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-23 09:11 +0000
Re: Looking under Python's hood: Will we find a high performance or clunky engine? Grant Edwards <invalid@invalid.invalid> - 2012-01-23 16:08 +0000
csiph-web