Cython-accelerated Django template engine for benchmarking template rendering speedup (3-14x faster)
Project description
django-templates-cythonized
Cython-accelerated drop-in replacement for Django's template engine. 3-14x faster depending on template complexity.
This is a benchmarking tool to evaluate what a Cython-level template speedup would bring to your project. Not meant for production use. Feel free to try though — if you run into issues, open an issue and I'll see if I can help.
Benchmarks
Measured on an AMD Ryzen 9 5950X, Python 3.14t (free-threaded).
| Benchmark | Cythonized | Stock Django | Speedup |
|---|---|---|---|
| 1000-book table (for/if/cycle/filters) | 2.4 ms | 33.7 ms | 14x |
| 50-book table + per-book forms (4 widgets/row) | 6.1 ms | 21.3 ms | 3.5x |
Usage
TEMPLATES = [
{
"BACKEND": "django_templates_cythonized.backend.CythonizedTemplates",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
}
]
For form-heavy templates, also set the form renderer:
FORM_RENDERER = "django_templates_cythonized.backend.CythonizedFormRenderer"
Development
git clone https://github.com/oliverhaas/django-templates-cythonized.git
cd django-templates-cythonized
uv sync --group dev
uv pip install -e . # Build Cython extensions
uv run pytest # Run tests
uv run pytest tests/benchmarks/ -v --no-cov -p no:codspeed # Run benchmarks
Re-run uv pip install -e . after modifying .py files to recompile.
Attribution & License
Contains modified copies of Django's template source code. BSD-3-Clause (matching Django). Benchmark structure inspired by django-rusty-templates.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_templates_cythonized-0.1.0.tar.gz.
File metadata
- Download URL: django_templates_cythonized-0.1.0.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f2b2e985edc17296644c2550294d95fad0be573c21a227547b4b143cf1d3b8b
|
|
| MD5 |
341be2835b9b8ac46174e4d0b30b469b
|
|
| BLAKE2b-256 |
ed25abed71349f018e521ab1161bcefa97fcbd88a8dab3e537a02b40c226fcf6
|
Provenance
The following attestation bundles were made for django_templates_cythonized-0.1.0.tar.gz:
Publisher:
publish.yml on oliverhaas/django-templates-cythonized
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_templates_cythonized-0.1.0.tar.gz -
Subject digest:
9f2b2e985edc17296644c2550294d95fad0be573c21a227547b4b143cf1d3b8b - Sigstore transparency entry: 1257807909
- Sigstore integration time:
-
Permalink:
oliverhaas/django-templates-cythonized@5ea76e8196326cbdef63be4016baf21616667a00 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ea76e8196326cbdef63be4016baf21616667a00 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_templates_cythonized-0.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: django_templates_cythonized-0.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.0 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be97d41b5a5a040697924a19661812ed0ef437e0f219cde2d3394a2494ef2a0f
|
|
| MD5 |
06cf6182f2580eca84d9361a3f2cd40b
|
|
| BLAKE2b-256 |
69fa908f3b7e73b12123b2ed4084cc4ff4773e3ef418da8cac54910b0b1b5eb7
|
Provenance
The following attestation bundles were made for django_templates_cythonized-0.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on oliverhaas/django-templates-cythonized
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_templates_cythonized-0.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
be97d41b5a5a040697924a19661812ed0ef437e0f219cde2d3394a2494ef2a0f - Sigstore transparency entry: 1257808082
- Sigstore integration time:
-
Permalink:
oliverhaas/django-templates-cythonized@5ea76e8196326cbdef63be4016baf21616667a00 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ea76e8196326cbdef63be4016baf21616667a00 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_templates_cythonized-0.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: django_templates_cythonized-0.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20c03aba534afaff36b1b76ffc68d9c79e04f2b9f60b5de52a02208b994bfb8c
|
|
| MD5 |
8fbacf774517b7fafd95fca071f88630
|
|
| BLAKE2b-256 |
248980a74477990943d3bb31fb8fe9afecd3662ca97bef0333805828507f487e
|
Provenance
The following attestation bundles were made for django_templates_cythonized-0.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on oliverhaas/django-templates-cythonized
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_templates_cythonized-0.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
20c03aba534afaff36b1b76ffc68d9c79e04f2b9f60b5de52a02208b994bfb8c - Sigstore transparency entry: 1257808203
- Sigstore integration time:
-
Permalink:
oliverhaas/django-templates-cythonized@5ea76e8196326cbdef63be4016baf21616667a00 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ea76e8196326cbdef63be4016baf21616667a00 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_templates_cythonized-0.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: django_templates_cythonized-0.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0472232f17651be3bffaaf14be946e3255596ca3973cc8c9e1cc4f7810182e4f
|
|
| MD5 |
3e63d820aa7da461b3c1d03115b57239
|
|
| BLAKE2b-256 |
01d6d78b33d21eac18b475df5b17823d5cd91f6e0e5a1b558594a8a574e9d8f9
|
Provenance
The following attestation bundles were made for django_templates_cythonized-0.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on oliverhaas/django-templates-cythonized
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_templates_cythonized-0.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
0472232f17651be3bffaaf14be946e3255596ca3973cc8c9e1cc4f7810182e4f - Sigstore transparency entry: 1257807982
- Sigstore integration time:
-
Permalink:
oliverhaas/django-templates-cythonized@5ea76e8196326cbdef63be4016baf21616667a00 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ea76e8196326cbdef63be4016baf21616667a00 -
Trigger Event:
workflow_dispatch
-
Statement type: