Is Perl *that* good?

Peter Hansen peter at engcorp.com
Tue Apr 27 14:36:34 EDT 2004


Skip Montanaro wrote:

>     Roy> I don't see anything in the reference manual which says re.match() 
>     Roy> caches compilations, but I suspect it does.
> 
> Yup, every call does.  I believe the only time you really need to compile
> them is if you have more than 100 different regular expressions.  In this
> case the caching code clears the cache when the threshold is reached instead
> of just picking a random few elements to toss (which seems like a mistake to
> me but one that should rarely be encountered).  

I would think the mistake would be in writing code that actually
depended on more than 100 different regular expressions, without
explicitly compiling the expressions itself.  The 100-expression
cache seems like a cheap, transparent optimization that shouldn't
cause anyone trouble in well-written code.

-Peter



More information about the Python-list mailing list