Curious to see alternate approach on a search/replace via regex
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Feb 7 22:02:14 EST 2013
Ian Kelly wrote:
> On Thu, Feb 7, 2013 at 4:59 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> Oh, one last thing... pulling out "re.compile" outside of the function
>> does absolutely nothing. You don't even compile anything. It basically
>> looks up that a compile function exists in the re module, and that's all.
>
> Using Python 2.7:
[...]
> Whatever caching is being done by re.compile, that's still a 24%
> savings by moving the compile calls into the setup.
That may or may not be the case, but rh didn't compile anything. He
moved "re.compile" literally, with no arguments, out of the timing code.
That clearly does nothing except confirm that re.compile exists.
--
Steven
More information about the Python-list
mailing list