ADR 0000: Build postc on previous work¶
Status: Final Type: Architecture Created: 2026-07
Context¶
postc implements the emerging POST Python standard and starts from work that already exists.
postpyc, the POST Python reference compiler created by Travis E. Oliphant and contributors, already has the piece that matters most: a backend-agnostic typed SSA IR feeding two working code generators (C and QBE), with the QBE output verified byte-identical to C. That IR is the hard part, the crown jewel this work is built on.
Behind it sits a longer lineage of ahead-of-time Python compilation that the standard sets out to unify. POST Python takes its conventions from that lineage: Numba, Cython, Pythran, Codon, mypyc, and taichi-lang. POST Python adopts Numba's @vectorize / @guvectorize ufunc model wholesale.
Our own earlier compilers feed in as directly:
- aopyc: an end-to-end AOT compiler for "Aopy", a small static language with Python syntax, emitting several targets (C, then gcc; x86 assembly) behind a
--list-backends/--all-backendsCLI. It is the direct ancestor of postc's runtime-selectable backend registry: the idea that one frontend, many code generators, chosen at run time is the right shape was proven there first. - p2w: a Python→WebAssembly compiler covering a broad slice of the language on WASM GC (with JS interop and browser demos). Its WAT-emission and assembly approach informs postc's WASM backend, though postc's numeric, unboxed value model diverges from p2w's boxed one.
- Prescrypt-NG: a Python→JavaScript transpiler over a well-defined subset, prioritizing correctness over completeness and held down by a large test suite. That subset-and-oracle discipline is exactly how postc is built and verified.
The open question was structure. postpyc's build driver selected a backend with a hardcoded if/else. Packaging was conda-first. The test, benchmark, and documentation layout was shaped around a single package. Four backends (C, QBE, and the planned llvmlite and WASM) need a different shape.
Decision¶
Build a new sibling package, postc ("POST Compiler"), on top of that previous work, explicitly a continuation of postpyc, with full credit to its authors, kept installable and comparable alongside it:
- Keep the proven core unchanged. The typed SSA IR, the frontend, the type checker, and both backends are lifted from postpyc essentially as-is.
- Rebuild the structure. A runtime-selectable backend registry over the IR, uv-first packaging, a test pyramid with a differential oracle, a benchmark harness, and this documentation.
- postpyc lives on as the POST Python reference implementation and postc's benchmark baseline (a development dependency). postc is where the multi-backend structure evolves; postpyc remains the reference.
Consequences¶
- Adding a backend costs exactly one IR→text lowering: every backend consumes the same IR, so no construct is ever implemented more than once per backend.
- A differential oracle (semantic vs CPython, plus byte-for-byte parity vs the C backend) can hold every backend to the same semantics, because they all consume identical IR.
- postc and postpyc diverge over time; the benchmark session history makes that divergence visible and holds postc's numbers to its baseline.
Alternatives considered¶
- Evolve postpyc in place. Rejected: it couples the reference implementation's stability to multi-backend churn, and conflates the baseline with the experiment.
- A monorepo or a branch. Rejected: postpyc must stay independently installable as postc's benchmark dependency; a separate sibling repository keeps that boundary clean.