Is Perl *that* good?
Roy Smith
roy at panix.com
Tue Apr 27 08:35:16 EDT 2004
Ville Vainio <ville at spammers.com> wrote:
> >>>>> "Asun" == Asun Friere <afriere at yahoo.co.uk> writes:
>
> Asun> Wouldn't you need to import the re module and compile the
> Asun> pattern first? (And wouldn't you use 'search' rather than
> Asun> 'match'?) And
>
> I rarely compile regexps, just pass the string to the re functions.
For the occasional ad-hoc match, this is fine. The advantage of
pre-compiling is that it's faster, since it doesn't have to recompile
the regex each time.
I don't see anything in the reference manual which says re.match()
caches compilations, but I suspect it does. Even a trivial check for
"thisRegEx is lastRegEx" would be sufficient to negate the speed
advantage of pre-compiling in most cases. Anybody know if it does this?
More information about the Python-list
mailing list