mir-backend-pythonlisted
Install: claude install-skill anantbhandarkar/make-it-right
# /mir-backend-python · Make It Right (Python runtime)
The middle tier. `mir-backend` decides **what is correct** (any language). The framework module (e.g. `mir-backend-python-fastapi`) knows the **library's mechanics**. This tier owns what's true for **all Python backends because they run on CPython** — the concurrency model and process model that FastAPI, Django, Flask, and Celery all inherit.
**Runtime assumed:** CPython 3.11+ (the notes hold for PyPy except where GIL specifics differ). Load order: `mir-backend` → `mir-backend-python` → `<framework module>`.
## The CPython footguns AI walks into (framework-agnostic)
### 1. The GIL — threads are NOT CPU parallelism
Python threads share one interpreter lock, so **CPU-bound work does not run in parallel across threads** — it serializes and you pay context-switch overhead on top. Threads only help **I/O-bound** work (the GIL releases during blocking I/O).
- CPU-bound (parsing, crypto, image/ML compute) → `multiprocessing` / `ProcessPoolExecutor`, a native extension that releases the GIL, or offload to a separate service. Never "add threads" expecting speedup.
- I/O-bound → threads or asyncio are fine.
- This is the runtime-level reason the runtime-map says "SKIP Python for heavily CPU-bound / microsecond-latency paths."
### 2. Async/sync "coloring" — pick one model per path and don't mix carelessly
An `async def` function can only be awaited from async context; a sync function that calls blocking I/O must not run on the