My brilliant (well, in my opinion) idea for a Python templating engine, performed somewhat less than brilliantly compared to the competition.
Tenjin, marketed as the fastest template engine in the world, blitzes through 10,000 pages in 5.61 seconds on a Mac Intel CoreDuo 1.83GHz (according to their website). The same benchmark runs on my Mac in about 4.98 seconds, so adjusting the other Python templating engines listed on Tenjin’s website by the same ~11% we get approximate performance of:
| pyTenjin (0.6.1) | 4.98 |
|---|---|
| Mako (0.1.9) | 12.01 |
| Myghty (1.1) | 17.18 |
| Cheetah (2.0) | 17.64 |
| Django (0.9.5) | 53.22 |
| Templetor (web.py 0.22) | 54.76 |
| Genshi (0.4.4) | 241.80 |
| Kid (0.9.6) | 337.27 |
The original version of Proton, for the same benchmark, came in at a less than impressive 400+ seconds. A bit of tidying up reduced the current version to a more respectable (but still abysmal) 280 seconds, putting it between Genshi and Kid. A couple of other ideas produced even worse performance (more than 800 seconds), but in the meantime, lxml released a Python3 compatible version. A minor rewrite later, and the lxml version of Proton now runs the benchmark in a far more acceptable 78 seconds. Putting it between Templetor and Genshi. Still not even in the top three, but it has the advantage (again in my opinion) of being an entirely more elegant solution, and is now within throwing distance of both Templetor and Django.
Result!
Get the latest version of Proton from the Google code project. You will probably need to download and install the source dist of lxml to take advantage of the performance improvement.


