> [gvanrossum, in an SF patch comment] > > Bah. I don't like this one bit. More complexity for a little > > bit of extra speed. > > I'm keeping this open but expect to be closing it soon unless I > > hear a really good argument why more speed is really needed in > > this area. Down with code bloat and creeping featurism! > > Without judging "the solution" here, "the problem" is that everyone's first > attempt to use line-at-a-time file input in Perl: > > while (<F>} { > ... $_ ...; > } > > runs 2-5x faster then everyone's first attempt in Python: > > while 1: > line = f.readline() > if not line: > break > ... line ... But is everyone's first thought to time the speed of Python vs. Perl? Why does it hurt so much that this is a bit slow? > It would be beneficial to address that *somehow*, cuz 2-5x isn't just "a > little bit"; and by the time you walk a newbie thru > > while 1: > lines = f.readlines(hintsize) > if not lines: > break > for line in lines: > ... line ... > > they feel like maybe Perl isn't so obscure after all <wink>. > > Does someone have an elegant way to address this? I believe Jeff's shot at > elegance was the other part of the patch, using (his new) xreadlines under > the covers to speed the fileinput module. But of course suggesting fileinput is also not a great solution -- it's relatively obscure (since it's not taught by most tutorials, certainly not by the standard tutorial). > reading-text-files-is-very-common-ly y'rs - tim So is worrying about performance without a good reason... --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4