any chance regular expressions are cached?
Terry Reedy
tjreedy at udel.edu
Sun Mar 9 22:14:26 EDT 2008
<mh at pixar.com> wrote in message
news:bu%Aj.5528$fX7.893 at nlpi061.nbdc.sbc.com...
| I've got a bit of code in a function like this:
|
| s=re.sub(r'\n','\n'+spaces,s)
| s=re.sub(r'^',spaces,s)
| s=re.sub(r' *\n','\n',s)
| s=re.sub(r' *$','',s)
| s=re.sub(r'\n*$','',s)
|
| Is there any chance that these will be cached somewhere, and save
| me the trouble of having to declare some global re's if I don't
| want to have them recompiled on each function invocation?
The last time I looked, several versions ago, re did cache.
Don't know if still true. Not part of spec, I don't think.
tjr
More information about the Python-list
mailing list