Added experimental and undocumented bytecode cache support
--HG--
branch : trunk
diff --git a/jinja2/environment.py b/jinja2/environment.py
index 00e3646..5b77d45 100644
--- a/jinja2/environment.py
+++ b/jinja2/environment.py
@@ -155,6 +155,11 @@
requested the loader checks if the source changed and if yes, it
will reload the template. For higher performance it's possible to
disable that.
+
+ `bytecode_cache`
+ If set to a bytecode cache object, this object will provide a
+ cache for the internal Jinja bytecode so that templates don't
+ have to be parsed if they were not changed.
"""
#: if this environment is sandboxed. Modifying this variable won't make
@@ -189,7 +194,8 @@
autoescape=False,
loader=None,
cache_size=50,
- auto_reload=True):
+ auto_reload=True,
+ bytecode_cache=None):
# !!Important notice!!
# The constructor accepts quite a few arguments that should be
# passed by keyword rather than position. However it's important to
@@ -225,7 +231,9 @@
# set the loader provided
self.loader = loader
+ self.bytecode_cache = None
self.cache = create_cache(cache_size)
+ self.bytecode_cache = bytecode_cache
self.auto_reload = auto_reload
# load extensions
@@ -248,7 +256,8 @@
line_statement_prefix=missing, trim_blocks=missing,
extensions=missing, optimized=missing, undefined=missing,
finalize=missing, autoescape=missing, loader=missing,
- cache_size=missing, auto_reload=missing):
+ cache_size=missing, auto_reload=missing,
+ bytecode_cache=missing):
"""Create a new overlay environment that shares all the data with the
current environment except of cache and the overriden attributes.
Extensions cannot be removed for a overlayed environment. A overlayed
@@ -497,7 +506,7 @@
variable_end_string, comment_start_string, comment_end_string,
line_statement_prefix, trim_blocks, newline_sequence,
frozenset(extensions), optimized, undefined, finalize,
- autoescape, None, 0, False)
+ autoescape, None, 0, False, None)
return env.from_string(source, template_class=cls)
@classmethod