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

Ezio Melotti ezio.melotti at gmail.com
Sat Mar 23 14:50:56 CET 2013


On Sat, Mar 23, 2013 at 3:34 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Sat, 23 Mar 2013 14:26:30 +0100
> Masklinn <masklinn at masklinn.net> wrote:
>>
>> Wouldn't it be better if there are *few* different regexes? Since the
>> module itself caches 512 expressions (100 in Python 2) and does not use
>> an LRU or other "smart" cache (it just clears the whole cache dict once
>> the limit is breached as far as I can see), *and* any explicit call to
>> re.compile will *still* use the internal cache (meaning even going
>> through re.compile will count against the _MAXCACHE limit), all regex
>> uses throughout the application (including standard library &al) will
>> count against the built-in cache and increase the chance of the regex
>> we want cached to be thrown out no?
>
> Well, it mostly sounds like the re cache should be made a bit smarter.
>

See http://bugs.python.org/issue17441.

Best Regards,
Ezio Melotti

> Regards
>
> Antoine.
>



More information about the Python-ideas mailing list