263.78 → 146.54 µs total CPU
44.4% lessPostgreSQL is 38.6% of current combined CPU; cursor/psycopg is another 44.8%.
A C++ port of Django 6.0.7
cppdjango is an open-source C++ port that keeps Django’s familiar API and behavior while moving performance-critical ORM paths into native code. The evidence: 436% faster framework-side ORM work across a balanced mix of measured PostgreSQL operations.
Install cppdjango 6.0.7.post1
Install the cppdjango distribution in a fresh virtual
environment. Applications continue to use import django
and the normal django-admin command.
The package includes native code. pip uses a compatible wheel when available and otherwise needs CMake, a recent C++26 compiler, OpenSSL, and zlib to build the extension.
$ python3 -m venv .venv $ . .venv/bin/activate $ python -m pip install --upgrade pip $ python -m pip install cppdjango==6.0.7.post1 # Verify the Python and native release identities $ python -c "import django; from django import native; print(django.__version__, native.version(), native.compiler())"
Use one distribution: cppdjango replaces upstream
Django. Do not install Django and cppdjango
together because both own the django import namespace.
Measured evidence
“Faster” here means more ORM operations for the same worker CPU. It does not mean PostgreSQL became faster, and it does not claim that every Django API is four times faster. It measures the framework work cppdjango actually replaces.
The aggregate gives one vote each to a point select, an ordered
32-row IN select, and a point update. Different production
mixes will produce different totals, so the operation-level results
remain visible below.
Across a balanced mix of measured PostgreSQL operations, cppdjango’s framework-side ORM work is 436% faster than stock Django 6.0.7.
Equivalent statement: cppdjango uses 81.4% less ORM CPU. Shared cursor/psycopg CPU and PostgreSQL CPU are excluded from this claim.
The unrounded ratio gives 436.4%, conservatively shown as 436%. The totals are one operation of each measured query shape.
Framework CPU / lower is better
These bars show worker CPU after subtracting a matched raw cursor call. That isolates query construction, ORM compilation, facade work, and framework result handling—the portion cppdjango can change.
| Query | Raw cursor floor stock / C++ |
Total worker stock / C++ |
ORM-only stock |
ORM-only C++ |
ORM CPU reduction |
CPU performance |
|---|---|---|---|---|---|---|
| Point select | 65.44 / 65.59 | 206.42 / 89.95 | 140.98 | 24.36 | 82.7% | 5.79× |
| Ordered IN32 | 80.36 / 80.40 | 276.87 / 113.08 | 196.51 | 32.68 | 83.4% | 6.01× |
| Point update | 65.31 / 65.08 | 157.30 / 88.10 | 91.99 | 23.01 | 75.0% | 4.00× |
ORM-only CPU = ORM worker CPU − the same build’s raw Django cursor/psycopg CPU. Using a per-build floor avoids assigning small installation variance to either framework.
Why the raw score is less heroic
Once cppdjango removes most framework work, the database and the shared cursor/driver path dominate. They account for 84–90% of current per-query CPU in these shapes. That fixed bill puts a hard ceiling on end-to-end gains.
PostgreSQL is 38.6% of current combined CPU; cursor/psycopg is another 44.8%.
PostgreSQL is 44.6% of current combined CPU; cursor/psycopg is another 39.4%.
PostgreSQL is 62.9% of current combined CPU; cursor/psycopg is another 27.4%.
Dedicated-backend task CPU was 57.36/56.59 µs for the point select, 90.71/90.94 µs for IN32, and 151.03/149.16 µs for the update. The native/stock difference stayed below 1.4%. The database did not get cheaper; cppdjango simply stopped spending so much Python CPU before and after it. That is why the measured query wall-time ratios—1.83× point, 1.85× IN32, and 1.24× update—are valuable but smaller than the 5.36× framework-only result.
What changed in the fork
The hot path keeps primitive predicates in an immutable C++ plan, resolves registered field IDs there, and binds the complete terminal without Python field hooks. Unsupported fields and values replay into Django before execution.
Preserve Django’s public API and select a conservative native candidate.
Resolve field IDs, validate primitives, bind parameters, and compile the terminal.
Execute and decode through the same driver used by stock Django.
Run the same SQL plan against the same rows and connection settings.
Controlled methodology
Worker CPU and PostgreSQL CPU were measured separately so blocked time could not masquerade as framework cost.
This result covers the measured PostgreSQL ORM fast paths. Cassandra, templates, middleware, unrelated QuerySet shapes, and application code are outside the claim.
RUSAGE_SELF, five-second steady state/proc, sampled at worker boundariesReproduce, don't trust
The published comparison preserves the exact measured patch, worker process records, PostgreSQL task-CPU records, construction samples, COW validation, boundary audit, and methodology.
# Published result and headline calculation $ curl -s https://django.goblinreactor.com/artifacts/benchmark-summary.json # Final worker, database, and construction samples $ curl -O https://django.goblinreactor.com/artifacts/cpu-process.csv $ curl -O https://django.goblinreactor.com/artifacts/cpu-postgresql.csv $ curl -O https://django.goblinreactor.com/artifacts/construction.csv # Exact measured patch SHA-256 9b3b89654bda36587ae782aac5cdbaa3d9f6b68257534c81b88053aade0c69da