[Patches] [Patch #102469] Use glibc's getline() extension

noreply@sourceforge.net noreply@sourceforge.net
Mon, 27 Nov 2000 14:15:56 -0800


Patch #102469 has been updated. 

Project: python
Category: core (C code)
Status: Accepted
Summary: Use glibc's getline() extension

Follow-Ups:

Date: 2000-Nov-21 19:15
By: akuchling

Comment:
(Inspired by a suggestion on comp.lang.python.) 

This patch changes the get_line() C function to use getline(),
a GNU libc extension, when it's available.  It does have a significant
impact; on my Linux box, reading the 6779-line quotations.xml
file takes 0.15 sec of CPU time using getline(), 0.45 sec without it.

Anyone know if C99 is adding an equivalent function?

Benchmark script:
import sys, time

f=open(sys.argv[1], 'r')

print 'Timing readline() for all lines'
cs = time.clock() ; start = time.time()
while 1:
    L = f.readline()
    if L == "": break

ce = time.clock() ; end = time.time()
print 'CPU time:', ce-cs, 'sec'
print 'Wall clock:', end-start, 'sec'


-------------------------------------------------------

Date: 2000-Nov-22 01:30
By: moshez

Comment:
In theory, I like this. In actual life, I'm a bit afraid of the implementation. You're just checking for the existence of a function named "getline". What if some other compiler
has such a function, and its semantics or signature differs? There's no pertinent standard on this. Maybe if would be best to enable if only if HAVE_GETLINE and something else
(like some define Glibc gives, if there is one).

-------------------------------------------------------

Date: 2000-Nov-27 13:37
By: gvanrossum

Comment:
I think Moshe is a little too worried here. Let's enable this. If there's a platform that has a different getline in its libc we'll find out soon enough (at the latest during alpha testing).

Andrew, go ahead and check it in.
-------------------------------------------------------

Date: 2000-Nov-27 13:58
By: akuchling

Comment:
OK.  I could add a check for the GNU libc and only use getline() if the compilation is using glibc, as Moshe suggests.  
This assumes that the name getline() or some equivalent isn't being standardized by C99.  


-------------------------------------------------------

Date: 2000-Nov-27 14:15
By: gvanrossum

Comment:
OK. Not worht more discussion.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=102469&group_id=5470