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

Ian Kelly ian.g.kelly at gmail.com
Fri Feb 8 09:21:39 CET 2013


On Thu, Feb 7, 2013 at 10:57 PM, rh <richard_hubbe11 at lavabit.com> wrote:
> On Thu, 7 Feb 2013 18:08:00 -0700
> Ian Kelly <ian.g.kelly at gmail.com> wrote:
>
>> Which is approximately 30 times slower, so clearly the regular
>> expression *is* being cached.  I think what we're seeing here is that
>> the time needed to look up the compiled regular expression in the
>> cache is a significant fraction of the time needed to actually execute
>> it.
>
> By "actually execute" you mean to apply the compiled expression
> to the search or sub? Or do you mean the time needed to compile
> the pattern into a regex obj?

The former.  Both are dwarfed by the time needed to compile the pattern.



More information about the Python-list mailing list