Faster Regular Expressions
Tim Peters
tim_one at email.msn.com
Thu Mar 9 22:25:05 EST 2000
[nkipp at vt.edu]
> Food for thought...
>
> My work depends on fast regular expressions but I also enjoy Python's
> ease and speed of development.
>
> I ran the following regular expression speed test (P166 workstation
> running Linux). The results are below. Function "fastMatch" can be
> six times (6x) faster.
In case that still isn't clear, he meant VI tick-tock tick-tock <wink>.
> It seems to me that Tatu Ylonen (apparent author of regexp.c) did his
> job well and that the re/mo wrapper in re.py slows everything down.
/F-redrik Lundh is working on a new (Unicode-aware) regexp pkg for Python
1.6. His speed tests confirmed the conventional wisdom here: regex has
much lower fixed overhead than re so generally wins on short strings; but re
is very often very much faster (even unboundedly so) than regex on long
strings (where the fixed overhead gets lost to the noise); and /F's pkg
appears to beat both on both counts -- at least according to his tests so
far.
btw-if-your-work-depends-on-fast-regexps-you-should-consider-
getting-a-real-job<wink>-ly y'rs - tim
More information about the Python-list
mailing list