Skip to content

v0.4.1

Choose a tag to compare

@MasonLyons MasonLyons released this 18 Oct 00:50
· 7 commits to main since this release

{% csrf_token %} and inclusion tags render faster. On the benchmark, csrf_token_loop goes from 12.5x to 20x faster than stock Django, and inclusion_tag from 4.1x to 6.9x.

pip install -U django-rust-templates

Faster

  • Context lookups by name (used by {% csrf_token %}, inclusion tags and other tags that read a fixed key) now do one dict probe per context layer instead of two, and no longer build a new key string for every layer.
  • Inclusion tags: copying csrf_token into the included template's context, building that context, and starting the child render all skip several Python calls. Each further call in a loop now costs about 2.8 µs, down from 5.0 µs.

Output stays byte-identical to stock Django. Context subclasses that override get are still called as before.