Templates, Evolved
AST-native. Free-threading ready. Zero regex.
Kida is a pure-Python template engine designed for Python 3.14t+. It compiles templates directly to Python AST—no string manipulation, no regex, no security vulnerabilities.
from kida import Environment
env = Environment()
template = env.from_string("Hello, {{ name }}!")
print(template.render(name="World"))
# Output: Hello, World!
Why Kida?
Compiles templates toast.Moduleobjects directly. No string concatenation, no regex parsing, no code generation vulnerabilities.
Built for Python 3.14t (PEP 703). Renders templates concurrently without the GIL. Declares_Py_mod_gil = 0.
Unified{% end %}for all blocks. Pattern matching with{% match %}. Pipelines with|>. Built-in caching.
Pure Python with no runtime dependencies. Includes nativeMarkupclass—no markupsafe required.
Quick Comparison
| Feature | Kida | Jinja2 |
|---|---|---|
| Compilation | AST → AST | String generation |
| Rendering | StringBuilder O(n) | Generator yields |
| Block endings | Unified{% end %} |
{% endif %},{% endfor %} |
| Async | Nativeasync for |
auto_await()wrapper |
| Pattern matching | {% match %} |
N/A |
| Free-threading | Native (PEP 703) | N/A |
Performance
StringBuilder rendering is 25-40% faster than Jinja2's generator pattern:
# Kida: O(n) StringBuilder
_out.append(...)
return "".join(_out)
# Jinja2: Generator yields (higher overhead)
yield ...
| Template Size | Kida | Jinja2 | Speedup |
|---|---|---|---|
| Small (10 vars) | 0.3ms | 0.5ms | 1.6x |
| Medium (100 vars) | 2ms | 3.5ms | 1.75x |
| Large (1000 vars) | 15ms | 25ms | 1.67x |
Zero Dependencies
Kida is pure Python with no runtime dependencies:
[project]
dependencies = [] # Zero!
Includes a nativeMarkupclass for safe HTML handling—no markupsafe required.