I've read great paper about generators:
Author say that it's easy to write analog of common linux tools such
as awk,grep etc. He say that performance could be even better.
But I have some problem with writing performance grep analog.
It's my script:
import re
pat = re.compile("som etext")
f = open("bigfile", 'r')
flines = (line for line in f if pat.search(line ))
c=0
for x in flines:
c+=1
print c
and bash:
grep "sometext" bigfile | wc -l
Python code 3-4 times slower on windows. And as I remember on linux
the same situation...
Buffering in open even increase time.
Is it possible to increase file reading performance?
Author say that it's easy to write analog of common linux tools such
as awk,grep etc. He say that performance could be even better.
But I have some problem with writing performance grep analog.
It's my script:
import re
pat = re.compile("som etext")
f = open("bigfile", 'r')
flines = (line for line in f if pat.search(line ))
c=0
for x in flines:
c+=1
print c
and bash:
grep "sometext" bigfile | wc -l
Python code 3-4 times slower on windows. And as I remember on linux
the same situation...
Buffering in open even increase time.
Is it possible to increase file reading performance?
Comment