[Python-ideas] re.compile_lazy - on first use compiled regexes

Antoine Pitrou solipsis at pitrou.net
Sat Mar 23 22:20:42 CET 2013


On Sat, 23 Mar 2013 22:19:02 +0100
"M.-A. Lemburg" <mal at egenix.com> wrote:
> 
> Hmm, I'm not following you. The patterns would get compiled once
> at Python build time when installing the stdlib. The bytecode
> version wouldn't change for those compiled patterns - unless, of
> course, you upgrade to a new Python version, but then you'd
> rebuild the bytecode versions of the REs :-)
> 
> To make them generally useful, I agree, you would have to add a
> RE compiler version to the bytecode pickle, but AFAICS this
> should not affect the usefulness for the stdlib RE cache.

Ah, you're talking only about the stdlib.
Well, sure, that would work, but we have to remember to regenerate
those pickles by hand each time the re bytecode is updated (which
doesn't happen often, admittedly). That's a bit of a maintenance burden.

> The whole idea is really very similar to the Python VM bytecode
> caching Python is using to speedup imports of modules.

Except that the VM bytecode caching works automatically and
transparently :-)

> Perhaps we could have a GSoC student give it a try and see
> whether it makes results in noticable startup time speedups ?!

That's a rather smallish topic for a GSoC project, IMHO.

Regards

Antoine.





More information about the Python-ideas mailing list