{% macro field(tag, heading, value) %}
{% if model_type == "anthropic" %}
<{{ tag }}>
{{ value }}
</{{ tag }}>
{% else %}
## {{ heading }}

{{ value }}
{% endif %}
{% endmacro %}
{% macro code_field(tag, heading, value) %}
{% if model_type == "anthropic" %}
<{{ tag }}>
```python
{{ value }}
```
</{{ tag }}>
{% else %}
## {{ heading }}

```python
{{ value }}
```
{% endif %}
{% endmacro %}
{{ code_field("original_source_code", "Original Source Code", original_source_code) }}
{{ code_field("optimized_source_code", "Optimized Source Code", optimized_source_code) }}
{{ field("original_line_profiler_results", "Original Line Profiler Results", original_line_profiler_results) }}
{{ field("optimized_line_profiler_results", "Optimized Line Profiler Results", optimized_line_profiler_results) }}
{{ field("original_code_runtime", "Original Code Runtime", original_code_runtime) }}
{{ field("optimized_code_runtime", "Optimized Code Runtime", optimized_code_runtime) }}
{{ field("speedup", "Speedup", speedup) }}
{{ field("annotated_tests", "Annotated Tests", annotated_tests) }}
{{ field("read_only_dependency_code", "Read-Only Dependency Code", read_only_dependency_code) }}
{% if model_type == "anthropic" %}
<original_explanation>
(Factual reference only — do NOT match its format or length)
{{ original_explanation }}
</original_explanation>
{% else %}
## Original Explanation (factual reference only)

{{ original_explanation }}
{% endif %}
{{ field("python_version", "Python Version", python_version) }}
{{ field("function_references", "Function References", function_references) }}
{% if include_throughput %}
{{ field("original_throughput", "Original Throughput (operations per second)", original_throughput) }}
{{ field("optimized_throughput", "Optimized Throughput (operations per second)", optimized_throughput) }}
{{ field("throughput_improvement", "Throughput Improvement", throughput_improvement) }}
{% endif %}
{% if include_concurrency %}
{{ field("original_concurrency_ratio", "Original Concurrency Ratio", original_concurrency_ratio) }}
{{ field("optimized_concurrency_ratio", "Optimized Concurrency Ratio", optimized_concurrency_ratio) }}
{{ field("concurrency_improvement", "Concurrency Improvement", concurrency_improvement) }}
{% endif %}
