Thursday, July 19, 2012

Python Fastest Template Engine

What is the fastest template system for Python? Django, Kid, Genshi are quite slow in compare to those used in this post. See also:
  • Comprehensive benchmarks for various template include, extends and widget directives are here.
The benchmark is based on wheezy.template big table test for rendering a 10x1000 HTML table in unicode. Latest available versions (September 24, 2014):
  1. bottle 0.12.7
  2. chameleon 2.16
  3. cheetah 2.4.4
  4. django 1.7
  5. jinja2 2.7.3
  6. mako 1.0.0
  7. durusworks qpy 1.2
  8. spitfire 0.7.15
  9. tenjin 1.1.1
  10. tornado 4.0.2
  11. web2py 2.0.9
  12. wheezy.template 0.1.155
Let setup virtualenv environment:
virtualenv env
env/bin/easy_install -O2 bottle chameleon cheetah django \
  jinja2 mako tenjin webext tornado wheezy.html \
  wheezy.template
Download bigtable.py test:
wget https://bitbucket.org/akorn/wheezy.template/raw/tip/demos/bigtable/bigtable.py
And run it:
env/bin/python bigtable.py