[Python-Dev] speed up readline() using getc_unlocked()

Andrew Kuchling akuchlin@mems-exchange.org
Wed, 3 Jan 2001 16:25:30 -0500


On Wed, Jan 03, 2001 at 03:45:38PM -0500, Guido van Rossum wrote:
>I'm ready to check these in, but I'm waiting 24 hours in case there's
>something I've missed.  (I haven't actually tested these on any other
>platform besides Linux.)

On Solaris 2.6, the configure script doesn't detect that
getc_unlocked() & friends are supported; details available from the
patch.  After editing config.h manually to enable them, the results are:

Before getc_unlocked patch:
total 1559913 chars and 32513 lines
count_chars_lines     0.892  0.730
readlines_sizehint    0.329  0.300
using_fileinput       4.612  4.470
while_readline        2.739  2.670

After patch:
total 1559913 chars and 32513 lines
count_chars_lines     0.698  0.680
readlines_sizehint    0.273  0.270
using_fileinput       2.707  2.700
while_readline        0.778  0.780
amarok src>           

With a patched version of fileinput.py:
using_fileinput       1.675  1.680

--amk