Skip to main content

Spitfire port forPython3

Project description

Spitfire

PyPI version

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.

This particular fork is made so that Spitfire can work with Python 3.

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 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] on linux
$ python tests/benchmarks/render_benchmark.py
Running benchmarks 1000 times each...

Genshi tag builder                            646.05 ms
Genshi template                               226.59 ms
Genshi template + tag builder                 448.92 ms
Mako Template                                  58.38 ms
Spitfire template                              33.79 ms
Spitfire template -O1                          20.66 ms
Spitfire template -O2                          12.94 ms
Spitfire template -O3                           8.19 ms
StringIO                                        7.95 ms
cStringIO                                       9.73 ms
list concat                                     7.32 ms
Jinja2 templates                               15.84 ms

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spitfire3-0.2.6.tar.gz (696.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spitfire3-0.2.6-py2.py3-none-any.whl (179.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file spitfire3-0.2.6.tar.gz.

File metadata

  • Download URL: spitfire3-0.2.6.tar.gz
  • Upload date:
  • Size: 696.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for spitfire3-0.2.6.tar.gz
Algorithm Hash digest
SHA256 afdf0b4db9a1d5e619a4e0416ec83997e28b16229bbe41b00813f64731e8e222
MD5 b354bee700eda377962458a2b9119bed
BLAKE2b-256 da3bf21c23d4182d80ffdf8a0eed41a1c63b5c06edb0b8d4edc8661e804a613e

See more details on using hashes here.

File details

Details for the file spitfire3-0.2.6-py2.py3-none-any.whl.

File metadata

  • Download URL: spitfire3-0.2.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 179.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for spitfire3-0.2.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7435c07f06df119574f5533b38533e6161a6af15b7e3d4c697c793945a15f13a
MD5 50a75e1a87a24d4f14000c9b15ca6bd7
BLAKE2b-256 9b9aed40116ce4a313689d26d711efa8ca140d6708efc289ba4f7ea1bc199d5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page