Metadata-Version: 2.4
Name: django-templates-cythonized
Version: 0.1.0
Summary: Cython-accelerated Django template engine for benchmarking template rendering speedup (3-14x faster)
Author-email: Oliver Haas <ohaas@e1plus.de>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://github.com/oliverhaas/django-templates-cythonized
Project-URL: Repository, https://github.com/oliverhaas/django-templates-cythonized.git
Keywords: django,templates,cython,performance
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django<7,>=5.2
Dynamic: license-file

# 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

```python
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:

```python
FORM_RENDERER = "django_templates_cythonized.backend.CythonizedFormRenderer"
```

## Development

```bash
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](https://github.com/romanroe/django-rusty-templates).
