# Specification: Data-Oriented Python Optimization Pass

## Overview
Perform an optimization pass and audit across the codebase (`./src` and `./simulation`), aligning the implementation with the Data-Oriented Design philosophy and the "less Python does the better" heuristic. Update the `product-guidelines.md` to formally document this approach for procedural Python code.

## Functional Requirements
1. **Update Product Guidelines:**
   - Formalize the heuristic that Python should act primarily as a procedural semantic definer (similar to how ImGui defines a UI DAG), delegating heavy lifting.
   - Enforce data-oriented guidelines for Python code structure, focusing on minimizing Python JIT overhead.
2. **Codebase Audit (`./src` and `./simulation`):**
   - Review global `src/` files and simulation logic against the new guidelines.
   - Identify bottlenecks that violate these heuristics (e.g., heavy procedural state manipulation in Python).
3. **Profiling & Instrumentation Expansion:**
   - Expand existing profiling instrumentation (e.g., `performance_monitor.py` or diagnostic hooks) if currently insufficient for identifying real structural bottlenecks.
4. **Optimization Execution:**
   - Refactor identified bottlenecks to align with the new data-oriented Python heuristics.
   - Re-evaluate performance post-refactor.
5. **C Extension Evaluation (Last Resort):**
   - If Python optimizations fail to meet performance thresholds, specifically identify and document routines that must be lowered to C/C++ with Python bindings. Only proceed with bindings if absolutely necessary.

## Non-Functional Requirements
- Maintain existing test coverage and strict type-hinting requirements.
- Ensure 1-space indentation and ultra-compact style rules are not violated during refactoring.
- Ensure the main GUI rendering thread is never blocked.

## Acceptance Criteria
- `product-guidelines.md` is updated with data-oriented procedural Python guidelines.
- `src/` and `simulation/` undergo a documented profiling audit.
- Identified bottlenecks are refactored to reduce Python overhead.
- No regressions in automated simulation or unit tests.
- A final report is provided detailing optimizations made and any candidates for future C extension porting.

## Out of Scope
- Actually implementing C/C++ bindings in this track (this track only identifies/evaluates them as a last resort; if needed, they get a separate track).
- Major UI visual theme changes.