Genshi Compiler 0.1.1

Genshi template compiler
Genshi Compiler is a tool that allows for compiling simple Genshi XML templates to pure Python code.

How to install:

- Download and install the source distribution or installer appropriate for you OS
- Execute easy_install genshi_compiler

Genshi Compiler allows for rendering your Genshi template to Python source code. You can save the code as a Python module or compile it into a directly usable module object in memory. Just call the render function on the module with your template parameters to render the whole template or any of your template functions to render those fragments separately.

According to my initial benchmarks the rendering speed is typically ~40x faster than doing the same using Genshi. There is a cost of this speedup, certainly. Some of Genshi's dynamic features are not available, most notably anything that depends on a template loader (xi:include), the XML element tree representation (py:match) or the token stream (filters).

Includes can be replaced by importing and calling other compiled template modules directly, so that is not a real limitation. Generic macro support (py:match) seems to be hopeless without slowing down the generated code considerably and loosing most of the performance gain. Token streams might be supported in the future.

This solution still allows you to speed up the most time critical parts (rendering large tables, trees, or lots of HTML user interface elements) considerably without too much effort, providing you can afford loosing the above functionality. It is also possible to combine Genshi and compiled template code for maximum flexibility and performance.

Python 3 support is planned.

last updated on:
July 19th, 2011, 8:57 GMT
price:
FREE!
homepage:
code.google.com
license type:
MIT/X Consortium License 
developed by:
Viktor Ferenczi
category:
ROOT \ Programming \ Compilers
Genshi Compiler
Download Button

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Rate it!

Add your review!

SUBMIT