On 3/24/2013 3:38 AM, Stefan Behnel wrote:
Gregory P. Smith, 24.03.2013 00:48:
In the absense of profiling numbers showing otherwise, i'd rather see all forms of manual caching like the conditional checks or a keep=True go away as it's dirty and encourages premature "optimization".
If I had been "more aware" of the re internal cache during the last years, I would have avoided at least a couple of re.compile() calls in my code, I guess.
Maybe this is something that the documentation of re.compile() can help with, by telling people explicitly that this apparently cool feature of pre-compiling actually has a drawback in it (startup time + a bit of memory usage) and that they won't notice a runtime difference in most cases anyway.
With a decent re cache size, .compile seems more like an attractive nuisance that something useful.