[Pythonmac-SIG] Re: [Python-Dev] Import hook to do end-of-line conversion?

Guido van Rossum guido@digicool.com
Thu, 12 Apr 2001 17:37:09 -0500


> I don't get it: why would a thin layer on top of stdio be bad? Seems
> much less work than reimplementing stdio.

Because by layering stuff you lose performance.  Example: fgets() is
often implemented in a way that is faster than you can ever do
yourself with portable code.  (Because fgets() can peek in the buffer
and see if there's a \n somewhere ahead, using memcmp() -- and if this
succeeds, it can use memcpy().  You can't do that yourself - only the
stdio implementation can.  And this is not a hypothetical situation --
Tim used fgets() for a significant speed-up of readline() in 2.1.

But if we want to use our own line end convention, we can't use
fgets() any more, so we lose big.

--Guido van Rossum (home page: http://www.python.org/~guido/)