Guido wrote:

> > > They *are* cached and there is no cost to using the functions instead
> > > of the methods unless you have so many regexps in your program that
> > > the cache is cleared (the limit is 100).
> > 
> > Sure there is; the cost of looking them up in the cache.
...
> > So in this (highly artificial toy) application it's about 7.5/2.5 = 3 times
> > faster to use the methods instead of the functions.
> 
> Yeah, but the cost is a constant -- it is not related to the cost of
> compiling the re.

True.

>                   (You should've shown how much it cost if you
> included the compilation in each search.)

Why should I have? I don't dispute that the caching helps -- I bet it
helps a *lot*. I was just observing that it's not true that there's
"no cost to using the functions instead of the methods".

> I haven't looked into this, but I bet the overhead you're measuring is
> actually the extra Python function call, not the cache lookup itself.

Hmm, that's possible. But what matters in practice is how big
the cost of using re.search("...","...") rather than compiling
once and using the RE object's search method is, not where it
comes from.

-- 
g

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to