• Stars
    star
    406
  • Rank 106,421 (Top 3 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created almost 9 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A high-performance Python template language

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

More Repositories

1

api-samples

Code samples for YouTube APIs, including the YouTube Data API, YouTube Analytics API, and YouTube Live Streaming API. The repo contains language-specific directories that contain the samples.
Java
5,477
star
2

spfjs

A lightweight JS framework for fast navigation and page updates from YouTube
JavaScript
2,230
star
3

doorman

Doorman: Global Distributed Client Side Rate Limiting.
Go
1,910
star
4

youtube-ios-player-helper

Lightweight helper library that allows iOS developers to add inline playback of YouTube videos through a WebView
Objective-C
1,650
star
5

yt-watchme

Java
340
star
6

cobalt

Cobalt is a lightweight HTML5 application container
C++
296
star
7

yt-direct-lite-android

The code is a reference implementation for an Android OS application that captures video, uploads it to YouTube, and submits the video to a YouTube Direct Lite instance.
Java
276
star
8

yt-direct-lite-iOS

The code is a reference implementation for an iOS application that captures video, uploads it to YouTube, and submits the video to a YouTube Direct Lite instance.
Objective-C
202
star
9

geo-search-tool

A tool to perform YouTube API v3 searches for videos tagged with geo-coordinates.
JavaScript
138
star
10

yt-android-player

Java
130
star
11

js_mse_eme

js_mse_eme is an externally-published tool that is aimed to test the validity of a browser's HTML5 Media Source Extension and Encrypted Media Extension implementations
JavaScript
91
star
12

youtubechatbot

This is a sample YouTube chat bot that's designed to run on Google App Engine. It leverages Task Queues to simulate a long-running background process which polls the YouTube LiveChatMessages API for the specified video.
83
star
13

youtube-chat-for-minecraft

A plugin for Minecraft Forge that provides an API for YouTube live chat services
Java
60
star
14

h5vcc

This is a minimal build of WebKit and Chromium sufficient to render an HTML5 video container for game consoles.
C++
58
star
15

yt-direct-lite-javascript

JavaScript
32
star
16

cobalt_sandbox

Cobalt dev workflow sandbox - this repo exists only as a CI sandbox. Please see http://cobalt.dev and https://github.com/youtube/cobalt
C++
21
star
17

yt-auto-curate-ruby

Ruby
15
star
18

h5vcc_hh

C++
15
star
19

yt-analytics-dump-ruby

Ruby
10
star
20

yt-shuffle-playlist-ruby

Ruby
10
star
21

rcat

A proposal for detecting engagement abuse of embedded third-party web content without depending on cookies.
Java
7
star
22

yt_channel_section_targeter

HTML
6
star
23

vfl

5
star
24

.github

3
star
25

.allstar

1
star