[Python-Dev] xreadlines : readlines :: xrange : range

Andrew Kuchling akuchlin@mems-exchange.org
Tue, 2 Jan 2001 16:06:05 -0500

On Tue, Jan 02, 2001 at 03:48:09PM -0500, Tim Peters wrote:
>into the FILE* representation in platform-dependent ways.  It's a shame that
>almost all vendors missed that fgets was defined as a primitive by the C
>committee precisely so that vendors *could* pull this speed trick under the
>covers.  It's also a shame that Perl did it for them <wink>.

So, should Python be changed to use fgets(), available on all ANSI C
platforms, rather than the glibc-specific getline()?  That would be
more complicated than the brain-dead easy course of using getline(),
which is obviously why I didn't do it; PyFile_GetLine() had annoyingly
complicated logic.

When this was discussed in comp.lang.python, someone also mentioned
getc_unlocked(), which saves the overhead of locking the stream every
time, but that didn't seem a fruitful avenue for exploration.