Python too slow for real world

Fredrik Lundh fredrik at pythonware.com
Mon May 3 09:34:36 EDT 1999


Robb Shecter wrote:
> Sorry if this is obvious, but does the Regex class cache compilations?  I
> couldn't find any info on this.  If it was, it would support subject matter
> experts nicely, like someone else mentioned.  But even as a CS person, I like
> how the Java "ORO" Regex Library has automatic Least Recently Used caching.
> This lets application code be simpler, as well as making it easier to share
> compiled expressions much more easily between objects.

re.py keeps up to 20 patterns in a cache
(see the _cachecompile function at the
top of that file).

(however, the cache cleaning code looks
a bit odd:

    if len(_cache) >= _MAXCACHE:
        _cache.clear()

maybe an LRU or a
del _cache[random.choice(_cache.keys())]
would be better?)

</F>





More information about the Python-list mailing list