how often does re.compile compile?

A.M. Kuchling amk at mira.erols.com
Mon Sep 6 16:38:30 EDT 1999


On Mon, 06 Sep 1999 19:20:08 GMT, 
	wade at lightlink.com <wade at lightlink.com> wrote:
>only within one function. If I say re.compile() inside the function
>definition, does the pattern get compiled afresh every time the function
>is called?

	Maybe.  There's a cache containing the most recent 20-odd
patterns, so if you're using fewer patterns, the re.compile() will do
a dictionary lookup, find the precompiled cached pattern, and just
return it without doing any more work, but the common idiom is to
precompile them yourself.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Actors... I don't like actors. It's a profession based on lies and disrespect.
Pretending to be what you are not.
    -- The emperor Augustus in SANDMAN #30: "August"





More information about the Python-list mailing list