When reading the documentation for the Python re module, I decided to look at the source code of re.py
When I opened it, I discovered the following:
_cache = {} _MAXCACHE = 100 def _compile(*key): cachekey = (type(key[0]),) + key p = _cache.get(cachekey) if p is not None: return p
Why is the cache cleared with _cache.clear() when it reaches _MAXCACHE entries?
Is a general approach to flushing the cache completely and starting from scratch?
Why didn't the longest time just be used when the lost value was deleted?
python regex caching
ovgolovin
source share