Skip to content
A high-performance Python template language
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Updated repository in docs as the one on Google Code is dead (#72) Nov 9, 2018
scripts Fix bug in crunner.py that prevents displaying error messages (#64) Aug 12, 2016
spitfire Make skip_filter work for built-in functions (#69) Jan 19, 2017
tests Add test case for falsey "if" values (#74) Mar 14, 2019
third_party Update import paths to use yappsrt from third_party Jan 23, 2016
.editorconfig
.gitignore
.style.yapf
.travis.yml
AUTHORS
CHANGES Added an additional change to prevent missing #global declarations fr… Feb 9, 2012
CONTRIBUTORS Updating CONTRIBUTORS to include me. Feb 12, 2016
LICENSE
Makefile
README.md Fix the README to have correct links. May 5, 2016
TODO
setup.py

README.md

Spitfire

Version Status

Introduction

Spitfire is a high-performance Python template language inspired by Cheetah. It originally started out as an experiment to see if techniques used in compilers were applicable to templates. Spitfire has been the primary template language for youtube.com since 2008 and is used to generate billions of views a day.

Example

<html>
<head><title>$title</title></head>
<body>
  <ul>
    #for $user in $users
      <li><a href="$user.url">$user.name</a></li>
    #end for
  </ul>
</body>
</html>

Getting Started

Spitfire's syntax is extremely similar to Cheetah, however some directives and language features have been omitted. If you're already using Cheetah, simple templates will likely compile in Spitfire, and there are a couple compatibility modes to ease transition.

Performance

Spitfire has a basic optimizer that can make certain operations much faster. Using a basic 10x1000 table generation benchmark, Spitfire can be faster than other template systems and compares very favorably to hand-coded Python (the upper limit of performance achievable by compiling to Python bytecode). This is by no means exhaustive proof that Spitfire is always fast, just that it can provide very high performance.

# Python 2.7.6 [GCC 4.8.2] on linux, 6-core Intel Xeon E5-1650 V3 @ 3.50GHz
$ python tests/benchmarks/render_benchmark.py  --compare --number 1000
Running benchmarks 1000 times each...

Cheetah template                               18.76 ms
Django template                               263.94 ms
Django template autoescaped                   262.89 ms
Jinja2 template                                 8.52 ms
Jinja2 template autoescaped                    18.22 ms
Mako template                                   3.25 ms
Mako template autoescaped                      11.45 ms
Python string template                         29.78 ms
Python StringIO buffer                         20.92 ms
Python cStringIO buffer                         5.93 ms
Python list concatenation                       2.30 ms
Spitfire template -O3                           6.60 ms
Spitfire template baked -O3                     8.15 ms
Spitfire template unfiltered -O3                2.17 ms
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.