Ricardo Aráoz [EMAIL PROTECTED] writes:
The easy/simple (too easy/simple?) way I see out of it is to read THE
WHOLE file into memory and don't worry. But what if the file is too
The easiest and simplest approach is often the best with
Python. Reading in the whole file is rarely too heavy, and
Ville M. Vainio wrote:
Ricardo Aráoz [EMAIL PROTECTED] writes:
The easy/simple (too easy/simple?) way I see out of it is to read THE
WHOLE file into memory and don't worry. But what if the file is too
The easiest and simplest approach is often the best with
Python.
Keep forgetting that!
Ville Vainio wrote:
On May 8, 8:11 pm, Ricardo Aráoz [EMAIL PROTECTED] wrote:
All these examples assume your regular expression will not span multiple
lines, but this can easily be the case. How would you process the file
with regular expressions that span multiple lines?
re.findall/
On Tue, 13 May 2008 00:03:08 +1000, Ricardo Aráoz [EMAIL PROTECTED]
wrote:
Ville Vainio wrote:
On May 8, 8:11 pm, Ricardo Aráoz [EMAIL PROTECTED] wrote:
All these examples assume your regular expression will not span
multiple
lines, but this can easily be the case. How would you process
On May 8, 8:11 pm, Ricardo Aráoz [EMAIL PROTECTED] wrote:
All these examples assume your regular expression will not span multiple
lines, but this can easily be the case. How would you process the file
with regular expressions that span multiple lines?
re.findall/ finditer, as I said earlier.
Anton Slesarev wrote:
I've read great paper about generators:
http://www.dabeaz.com/generators/index.html
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
Alan Isaac wrote:
Anton Slesarev wrote:
I've read great paper about generators:
http://www.dabeaz.com/generators/index.html 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
Anton Slesarev wrote:
I try to save my time not cpu cycles)
I've got file which I really need to parse:
-rw-rw-r-- 1 xxx xxx 3381564736 May 7 09:29 bigfile
That's my results:
$ time grep python bigfile | wc -l
2470
real0m4.744s
user0m2.441s
sys 0m2.307s
And python
I try to save my time not cpu cycles)
I've got file which I really need to parse:
-rw-rw-r-- 1 xxx xxx 3381564736 May 7 09:29 bigfile
That's my results:
$ time grep python bigfile | wc -l
2470
real0m4.744s
user0m2.441s
sys 0m2.307s
And python scripts:
import sys
if
On May 6, 10:42 pm, Anton Slesarev [EMAIL PROTECTED] wrote:
flines = (line for line in f if pat.search(line))
What about re.findall() / re.finditer() for the whole file contents?
--
http://mail.python.org/mailman/listinfo/python-list
Anton Slesarev wrote:
But I have some problem with writing performance grep analog.
I don't think you can ever catch grep. Searching is its only purpose in
life and its very good at it. You may be able to come closer, this
thread relates.
On May 7, 7:22 pm, Pop User [EMAIL PROTECTED] wrote:
Anton Slesarev wrote:
But I have some problem with writing performance grep analog.
I don't think you can ever catch grep. Searching is its only purpose in
life and its very good at it. You may be able to come closer, this
thread
I've read great paper about generators:
http://www.dabeaz.com/generators/index.html
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:
On Tue, May 6, 2008 at 1:42 PM, Anton Slesarev [EMAIL PROTECTED] wrote:
Is it possible to increase file reading performance?
Dunno about that, but this part:
flines = (line for line in f if pat.search(line))
c=0
for x in flines:
c+=1
print c
could be rewritten as just:
print
Anton Slesarev [EMAIL PROTECTED] writes:
f = open(bigfile,'r')
flines = (line for line in f if pat.search(line))
c=0
for x in flines:
c+=1
print c
It would be simpler (and probably faster) not to use a generator expression:
search = re.compile('sometext').search
c = 0
for line in
2008/5/6, Anton Slesarev [EMAIL PROTECTED]:
But I have some problem with writing performance grep analog.
[...]
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
16 matches
Mail list logo