[Python-ideas] re.compile_lazy - on first use compiled regexes
Stephen J. Turnbull
stephen at xemacs.org
Thu Mar 28 03:42:57 CET 2013
Terry Reedy writes:
> With a decent re cache size, .compile seems more like an attractive
> nuisance that something useful.
In applications like text editors, you often have scads of ephemeral
regexps (entered by users) but some you'd like to keep around
(python_keyword_re, for example). I don't know if this is actually a
performance hit in such applications, but like Steven d'A, I'm not
comfortable in relying on a cache for performance-critical apps. It
seems to me that the cache is a backstop to reduce the chance that an
application repeatedly compiles a given regexp in an inner loop, but
can't guarantee elimination of all such performance problems.
I'm also not clear on why you consider it an attractive nuisance.
It's annoying enough that people will only do it for regexps they
consider important, so I doubt people will be compiling thousands of
regexps that only get used once in a blue moon. What's the loss to
having the facility available (aside from the overhead of maintenance
and documentation -- "attractive nuisance" implies users with holes in
their feet :-)?
More information about the Python-ideas