> >Summary: speed up readline() using getc_unlocked() > > So what does the performance of this version look like? Very slightly faster than the GNU getline() version. Without GNU getline, the old code was about 3.5 times slower. Here are the current times on a 6 Mb file (fileinput.py has my sourceforge speedup patch too): $ ./python ~/rltest.py ~/termcapx10 total 6252720 chars and 146250 lines; average line length 42.8 count_chars_lines 0.943 0.930 readlines_sizehint 0.544 0.540 using_fileinput 2.089 2.090 while_readline 0.956 0.960 For comparison, here's what Python 1.5.2 does with the same test (which should be pretty close to what the released Python 2.0 does; I don't have a copy of that handy). $ python1.5 ~/rltest.py ~/termcapx10 total 6252720 chars and 146250 lines; average line length 42.8 count_chars_lines 0.836 0.820 readlines_sizehint 0.523 0.520 using_fileinput 5.739 5.740 while_readline 3.670 3.670 I don't know why count_chars_lines got proportionally more slower than readlines_sizehint. (The += operator didn't make a difference either way.) --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