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

noreply@sourceforge.net noreply@sourceforge.net
Tue, 21 Nov 2000 19:15:00 -0800


Patch #102469 has been updated. 

Project: python
Category: core (C code)
Status: Open
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'


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

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

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