From 90c0e0ff7e3e31915b205043a8cd1bd699d012e4 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 3 Sep 2012 08:09:49 -0500 Subject: [PATCH] CACHED_REGEXES_MAX_SIZE, thanks Anthony --- VERSION | 2 +- gluon/compileapp.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 886c6d0e..9a3437b2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.6 (2012-09-02 22:34:20) stable +Version 2.0.6 (2012-09-03 08:09:45) stable diff --git a/gluon/compileapp.py b/gluon/compileapp.py index 70d5f6c9..6873ca74 100644 --- a/gluon/compileapp.py +++ b/gluon/compileapp.py @@ -92,11 +92,14 @@ _TEST() """ CACHED_REGEXES = {} +CACHED_REGEXES_MAX_SIZE = 1000 def re_compile(regex): try: return CACHED_REGEXES[regex] except KeyError: + if len(CACHED_REGEXES) >= CACHED_REGEXES_MAX_SIZE: + CACHED_REGEXES.clear() compiled_regex = CACHED_REGEXES[regex] = re.compile(regex) return compiled_regex