Coder Social home page Coder Social logo

watsonhaw / spitfire Goto Github PK

View Code? Open in Web Editor NEW

This project forked from youtube/spitfire

0.0 2.0 0.0 589 KB

A high-performance Python template language

License: BSD 3-Clause "New" or "Revised" License

Makefile 1.01% Python 88.23% GAP 5.43% C 4.25% PHP 0.26% Smarty 0.03% HTML 0.79%

spitfire's Introduction

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

spitfire's People

Contributors

msolo avatar nicksay avatar shalabhc avatar awbraunstein avatar jnlopar avatar gnoack avatar googlecodeexporter avatar kcomer avatar jfries avatar benjaminlistwon avatar atubbs avatar bursauxa avatar nairb774 avatar hannosch avatar jvaidya avatar kssilveira avatar flatfeetpete avatar ryankennedy avatar

Watchers

James Cloos avatar 王阿觉 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.