SRE vs PRE: speed

Fredrik Lundh fredrik at pythonware.com
Fri Jul 6 23:25:56 CEST 2001


Oleg Broytmann wrote:
> My company doen't want to switch from python 1.5.2 to 2.0+ - our CTO is
> very disappointed with SRE speed. SRE is 3-4 times lsower.

you cannot really use profile to compare C code with
Python code.  if you use time.time or time.clock, you'll
notice that the difference isn't quite as large as you
think...

> Any plans to make it faster?

sure.

but the priority this far has been "match" and "search", not
"sub".  change your benchmark to use "search" or "findall",
and you'll find that SRE is 5-10 times faster than PRE.

and you can easily make your code faster without having
to wait for an upgrade: just use the string.replace function
instead.  it's about 15 times faster than PRE on this one...

(25 times faster if you use unicode strings ;-)

</F>





More information about the Python-list mailing list