Curious to see alternate approach on a search/replace via regex

Ian Kelly ian.g.kelly at gmail.com
Fri Feb 8 11:26:58 EST 2013


On Fri, Feb 8, 2013 at 4:43 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Ian Kelly wrote:
> Surely that depends on the size of the pattern, and the size of the data
> being worked on.

Natually.

> Compiling the pattern "s[ai]t" doesn't take that much work, it's only six
> characters and very simple. Applying it to:
>
> "sazsid"*1000000 + "sat"
>
> on the other hand may be a tad expensive.
>
> Sweeping generalities about the cost of compiling regexes versus searching
> with them are risky.

I was referring to the specific timing measurements I made earlier in
this thread, not generalizing.



More information about the Python-list mailing list