[Python-Dev] xreadlines : readlines :: xrange : range
Guido van Rossum
guido@python.org
Thu, 04 Jan 2001 10:27:28 -0500
[Me & Thomas in violent agreement that there's something weird about
the speed of getc_unlocked() vs. getc() on FreeBSD.]
I just realized what's the probable cause. Read your timing post
again:
# BSDI:
#
# (Python 2.0)
# while_readline 1.006 1.000
#
# (CVS Python + getc_unlocked)
# while_readline 0.363 0.367
# FreeBSD:
#
# (Standard CVS Python)
# while_readline 0.214 0.219
#
# (CVS+getc_unlocked)
# while_readline 0.283 0.281
Standard CVS Python, as opposed to Python 2.0 as released, uses GNU
getline()! So on FreeBSD, for this test case, GNU getline() is faster
than getc_unlocked().
So the question is, should I leave the GNU getline() code in? I'm
inclined against it -- it's not that much faster, and on other
platform getc_unlocked() is faster. Given that getc_unlocked() is a
standard (of some sort) and GNU getline() is, well, just that, I'd say
let's stick with getc_unlocked().
(Unfortunately, from a phone conversation I had last night with Tim,
there's not much hope of doing something there -- and that platform
sorely needs it! The hacks that Tim reported earlier are definitely
not thread-safe. While it's easy to come up with getc_unlocked() for
Windows, the locking operations used internally there by the /MT code
are not exported from MSVCRT.DLL, and that's crucial.)
--Guido van Rossum (home page: http://www.python.org/~guido/)