[Python-Dev] xreadline speed vs readlines_sizehint

Tim Peters tim.one@home.com
Mon, 15 Jan 2001 01:35:05 -0500

> At this point I'm +0.5 on the idea of fileobject.c using
> ms_getline_hack whenever HAVE_GETC_UNLOCKED isn't available.

[NeilS, from Wednesday]
> Compare ms_getline_hack to what Perl does in order speed up IO.

Believe me, I have <wink>.

> I think its worth maintaining that piece of relatively portable
> code given the benefit.  If the code has to be maintained then it
> might was well be used.  If we find a platform the breaks we can
> always disable it before the final release.

Given that hearty encouragement, and the utterly non-scary results so far, I
just checked in a new scheme:

On a platform with getc_unlocked():
    By default, use getc_unlocked().
    If you want to use fgets() instead, #define USE_FGETS_IN_GETLINE.
        [so motivated people can use fgets() instead if it's faster
         on their platform]
On a platform without getc_unlocked():
    By default, use fgets().
    If you don't want to use fgets(), #define DONT_USE_FGETS_IN_GETLINE.
        [so if we stumble into a platform it fails on between
         releases, the user will have an easy time turning it off