Skip to content

v0.4.3

Latest

Choose a tag to compare

@MasonLyons MasonLyons released this 18 Oct 14:48
· 1 commit to main since this release

truncatechars_html, truncatewords_html, filesizeformat and humanize's intword now render fast. Before this release they ran only 1.2–1.5x faster than stock Django. On the benchmark, {{ html|truncatechars_html:20 }} is now 15x faster than stock, truncatewords_html 13x, {{ n|intword }} 15x and {{ n|filesizeformat }} 10x.

pip install -U django-rust-templates

Faster

  • truncatechars_html / truncatewords_html: Django runs Python's HTMLParser over every value. The native version reproduces the parser's behaviour, quirks included, for ordinary HTML: plain tags with attributes, and common entity references such as &,   and '.
  • filesizeformat and intword (django.contrib.humanize): integer inputs are formatted natively. Their translated unit strings are looked up once per active translation instead of on every call.

Output stays byte-identical to stock Django, on every supported Python version. Comments, <script>/<style> content, a bare < or &, unusual entities, non-integer numbers and patched module globals still run the Python code.