Chameleon templates, modernized: a Rust engine that runs Chameleon templates unchanged, several times faster, with async rendering and built-in framework integrations.
pip install chameleon-rs Copy PIP instructions
Chameleon templates, modernized. Several times faster.
chameleon-rs is Chameleon's template language on a new engine written in Rust. Your existing templates and code run unchanged, with byte-identical output, several times faster. It also adds what a modern Python web app expects: async rendering that never blocks the event loop, built-in integrations for Flask/Quart, FastAPI, Starlette, Robyn and Litestar, partials, Markdown, and support for free-threaded Python. No runtime dependencies.
Documentation: https://mkennedy.codes/docs/chameleon-rs/ · Changelog · Compatibility · Performance
pip install chameleon-rs # or: uv pip install chameleon-rs CPython 3.12 to 3.15, including the free-threaded builds (3.14t, 3.15t). Wheels for Linux (glibc and musl), macOS and Windows contain the compiled engine, so no Rust toolchain is needed. Stock Chameleon need not be installed.
Switching an application is one line at startup, before anything imports Chameleon:
import chameleon_rs.compat chameleon_rs.compat.install() From then on import chameleon gives chameleon-rs, and so do chameleon_partials, chameleon_flask, fastapi_chameleon and chameleon_robyn. Your templates and the code around them stay as they are.
Templates are Chameleon's: HTML with tal: attributes and ${...} expressions, so a template is still valid HTML that an editor or browser can open.
from chameleon_rs import PageTemplate page = PageTemplate(' Hello, ${name}!
') print(page(names=['World', 'Rust'])) In a web app, point chameleon-rs at a template folder and decorate your views. With FastAPI:
import fastapi import chameleon_rs.fastapi as fastapi_chameleon app = fastapi.FastAPI() fastapi_chameleon.configure(template_folder='templates', app=app) @app.get('/episodes/{number}') # the route decorator first... @fastapi_chameleon.template('episodes/detail.pt') # ...then @template async def detail(number: int): episode = await db.episode(number) if episode is None: fastapi_chameleon.not_found() return {'episode': episode} The view keeps its signature, so path and query parameters, Depends, validation and the OpenAPI docs work as without @template. Getting started.
Web frameworks shows the same page in each one. Each module keeps the API of the library it replaces and adds the same decorator API (configure, @template, render, response, not_found, error, render_async, response_async, check_views).
Template names come from your code. The decorator modules and render_partial() look names up as the original libraries do (.. and absolute paths work), so never build one from request data. Starlette's Templates and Litestar's ChameleonEngine refuse names that reach outside their folder, as Jinja does.
In synthetic benchmarks (release build, same process, interleaved with Chameleon): listings 6.6x faster per item, macro calls 6.9x, an app-shaped page 4.3x, native partials 10.9x, and templates compile about 70x faster. On a production Quart site, template rendering was 2.2x faster in total and whole requests 1.3x faster; under load, throughput rose 34%. The released wheels are profile-guided, about 10% faster again. How it's measured.
chameleon template templates page templates zpt tal metal html rust flask quart fastapi starlette robyn litestar
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Enable javascript to be able to filter the list of wheel files.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
Yanked reason: Security weakens, fixed in 0.1.48.




