C
Christos Georgiou
He's 37 years old! How long should one be given to mature?
I (lots of female friends, actually believe many men remain in
puberty for longer than that.
He's 37 years old! How long should one be given to mature?
Xah said:i switched to system call with tail because originally i was using a
pure Python solution
inF = gzip.GzipFile(ff, 'rb');
s=inF.readlines()
inF.close()
last_line=s[-1]
and since the log file is 100 megabytes it takes a long time and hogs
massive memory.
Fredrik said:zcat|tail is a LOT faster.
Fredrik said:Fredrik said:zcat|tail is a LOT faster.
and here's the "right way" to use that:
from subprocess import Popen, PIPE
p1 = Popen(["zcat", filename], stdout=PIPE)
p2 = Popen(["tail", "-1"], stdin=p1.stdout, stdout=PIPE)
last_line = p2.communicate()[0]
(on my small sample, this is roughly 15 times faster than the empty for loop)
</F>
Xah said:isn't there a way to implement tail in python with the same class of
performance?
how's tail implemented?:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.