Repository navigation
v0.2.0
Faster rendering for real pages: the slow paths that a page rendered the way a view does hits (backend + request, context processors, forms, i18n, aware datetimes, humanize) were mostly bridged Python. On the new end-to-end benchmark, benchmarks/realworld.py, the Rust engine went from 1.5x → 2.6x faster than stock Django.
pip install -U django-rust-templatesNew
-
RustFormRenderer: Django's defaultFORM_RENDERERbuilds its own stock template engine, so form and widget HTML never went throughRustTemplates. To render it natively too, set:FORM_RENDERER = "django_rust_templates.forms.RustFormRenderer"
It uses the same templates and produces identical output, about 2.6x faster. The Django admin change form renders in 9.6 ms with it, vs 17.0 ms on stock.
Faster
- Aware datetimes (
USE_TZ=True, Django's default): timezone conversion is native, saving ~9 µs per value. Also speeds up{% now %}. date/timefilters: the'c'format and locale-named formats (bare|date,SHORT_DATE_FORMAT,TIME_FORMAT) went from 1.3–1.6x to 8–13x.{% translate "literal" %}is native (1.2x → 7.3x), and lazy translations (gettext_lazylabels and verbose names) render 4.5x faster.striptagsis native for ordinary HTML (1.4x → 28x). Anything unusual still uses Django's ownstrip_tags.- humanize
intcommaon integers: 1.7x → 10.9x, with locale grouping and separators. {% url %}: 6.8 → 4.4 µs.
Fixes
copy.deepcopy()of a nativeEnginenow works. Before, deep-copyingform.errorsfailed when forms rendered throughRustTemplates.- The active language is no longer read stale after Django swaps out its translation state, which happens on settings changes and when the dev server's autoreloader reloads translation files.
- Language lookups now follow Django's own
trans_real/trans_nullchoice exactly.
Known gaps
- The body of a bridged block tag (
{% localtime %},{% cache %}, third-party block tags) still renders at stock speed. {% blocktranslate %},{% static %}and humanizenaturaltimeare still Python.
Output stays byte-identical to stock Django. Django's template test suite passes 100% on 5.2 and 6.1, and Django's forms, admin, i18n, humanize and timezones test apps also pass when run through the Rust engine.
Full change: #1