Repository navigation
v0.4.2
The |localtime, |utc and |timezone filters and humanize's |ordinal now render fast. Before this release they ran at about the same speed as stock Django. On the benchmark, {{ value|timezone:"…" }} is now 9.8x faster than stock, {{ value|localtime }} 5.2x and {{ n|ordinal }} 24x.
pip install -U django-rust-templatesFaster
- Time zone filters:
localtime,utcandtimezonereturn Django'sdatetimeobject(adatetimesubclass). Printing that value, or passing it on to|date/|time, used to fall back to Python's date formatting. These values now take the same native path as plain datetimes. ordinal(django.contrib.humanize): Django looks up all ten suffix translations on every call. The native version looks up only the one it needs.
Output stays byte-identical to stock Django. Subclasses of datetimeobject, inputs to ordinal other than plain ints, and patched humanize module globals still run the Python code.