Re: Can I beat perl at grep-like processing speed?

2007-01-03 Thread Fredrik Lundh
Nick Craig-Wood wrote: >> #!/usr/bin/env python >> import re >> r = re.compile(r'destroy', re.IGNORECASE) >> >> for s in file('bigfile'): >>if r.search(s): print s.rstrip("\r\n") footnote: if you're searching for literal strings with Python 2.5, using "in" is a lot faster than using re.s

Re: Can I beat perl at grep-like processing speed?

2007-01-02 Thread Bruno Desthuilliers
js a écrit : > Just my curiosity. > Can python beats perl at speed of grep-like processing? Probably not. > > $ wget http://www.gutenberg.org/files/7999/7999-h.zip > $ unzip 7999-h.zip > $ cd 7999-h > $ cat *.htm > bigfile > $ du -h bigfile > du -h bigfile > 8.2Mbigfile > > -- grep.

Re: Can I beat perl at grep-like processing speed?

2006-12-29 Thread Nick Craig-Wood
js <[EMAIL PROTECTED]> wrote: > Just my curiosity. > Can python beats perl at speed of grep-like processing? > > $ wget http://www.gutenberg.org/files/7999/7999-h.zip > $ unzip 7999-h.zip > $ cd 7999-h > $ cat *.htm > bigfile > $ du -h bigfile > du -h bigfile > 8.2M bigfile > > #!/usr/l

Re: Can I beat perl at grep-like processing speed?

2006-12-29 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Tim Smith wrote: > also, if you replace the regex with a test like lambda x: > x.lower().find("destroy") != -1, you will get really close to the speed > of perl's Testing for ``'destroy' in x.lower()`` should even be a little bit faster. Ciao, Marc 'BlackJack' Rin

Re: Can I beat perl at grep-like processing speed?

2006-12-29 Thread Tim Smith
you may not be able to beat perl's regex speed, but you can take some steps to speed up your python program using map and filter here's a modified python program that will do your search faster #!/usr/bin/env python import re r = re.compile(r'destroy', re.IGNORECASE) def stripit(x): return

Re: Can I beat perl at grep-like processing speed?

2006-12-29 Thread Christophe Cavalaria
js wrote: > Just my curiosity. > Can python beats perl at speed of grep-like processing? > > > $ wget http://www.gutenberg.org/files/7999/7999-h.zip > $ unzip 7999-h.zip > $ cd 7999-h > $ cat *.htm > bigfile > $ du -h bigfile > du -h bigfile > 8.2M bigfile > > -- grep.pl -- >

Can I beat perl at grep-like processing speed?

2006-12-29 Thread js
Just my curiosity. Can python beats perl at speed of grep-like processing? $ wget http://www.gutenberg.org/files/7999/7999-h.zip $ unzip 7999-h.zip $ cd 7999-h $ cat *.htm > bigfile $ du -h bigfile du -h bigfile 8.2Mbigfile -- grep.pl -- #!/usr/local/bin/perl open(F, 'bigfile