datasette/perf/request-response/patches/template-plumbing-2-buffer-base-content-block.diff
Claude d1dbb40362
Add request/response profiling harness and proposed optimisation patches
Tools for profiling Datasette's request/response cycle in-process with
Python 3.15's profiling.sampling, plus the patches proposed by the study
(one per optimisation, and ALL-combined.diff). The patches are not
applied to the code. A report with measurements follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F8mEgRS8swZfYqwqrVMeo5
2026-10-13 00:12:35 +00:00

15 lines
772 B
Diff

diff --git a/datasette/templates/base.html b/datasette/templates/base.html
index 1c5b833..cff9c82 100644
--- a/datasette/templates/base.html
+++ b/datasette/templates/base.html
@@ -34,8 +34,8 @@
{% endblock %}
<section class="content">
-{% block content %}
-{% endblock %}
+{# Rendering into a variable and outputting it once is much faster than yielding every fragment up through the async block/extends generators. The with block keeps content_html out of the template context, so it cannot shadow a content_html variable used by later blocks #}{% with %}{% set content_html %}{% block content %}
+{% endblock %}{% endset %}{{ content_html }}{% endwith %}
</section>
</div>
<footer class="ft">{% block footer %}{% include "_footer.html" %}{% endblock %}</footer>