Skip to main content

MEP-51 research bundle: Mochi to Python transpiler

Author: research pass for MEP-51 (Mochi to Python transpiler). Date: 2026-05-23 (GMT+7).

This bundle contains the twelve research notes that informed MEP-51, the Mochi-to-Python transpiler. The notes are informative; the normative spec is in the MEP body.

#TitleTopic
01Language surfaceMochi language surface mapped onto CPython 3.12 lowering obligations
02Design philosophyWhy Python, why CPython 3.12 floor, why dual mypy + pyright strict gates, why asyncio.Queue + TaskGroup over Trio / AnyIO / actor frameworks
03Prior artSurvey of source-to-Python tooling: 2to3, libcst, Cython, mypyc, Nuitka, Brython, Transcrypt, RustPython, Jython, IronPython, GraalPy, Mojo, LPython, Codon, pytype, pyrefly
04RuntimeThe mochi_runtime PyPI package: stdlib + httpx + agent supervisor + Datalog evaluator + JSONValue + MochiResult + ZonedDateTime + ctypes FFI
05Codegen designIR-to-Python lowering via Go-side AST + ast.unparse + ruff format, monomorphisation, closure conversion, match-to-decision-tree, source maps
06Type loweringPer-type details for every Mochi type onto Python 3.12 (int, float, str, list, dict, OrderedSet, frozen-slots @dataclass, PEP 695 sum types, `T
07Target portabilityCPython 3.12.0 / 3.12.7 / 3.13.0 matrix x linux/macos/windows x x86_64/arm64, wheel platform tags, abi3 stance, uv-managed Python, v1 exclusions (PyPy, Cython, mypyc, Nuitka, Pyodide)
08Dataset pipelineQuery DSL lowering via generator expressions + itertools + AsyncIterator, hash/merge/nested-loop joins, Datalog semi-naive evaluation, deliberate rejection of pandas / polars / DuckDB
09Agents and streamsMochi agents as a custom class wrapping asyncio.Queue[Message] + TaskGroup supervision (PEP 654 ExceptionGroup), AsyncIterator[T] streams, cold/hot patterns, GIL story
10Build systempyproject.toml (PEP 621) + hatchling backend + uv 0.4+ as canonical driver, wheel + sdist, PyPI Trusted Publishing (OIDC + sigstore + PEP 740), Jupyter ipykernel target
11Testing gatesPer-phase Go test gates, CPython 3.12.0 / 3.13.0 matrix, mypy 1.13 + pyright 1.1.380 strict, ruff fixed-point, wheel build+install smoke test, ~400-fixture corpus by Phase 18
12Risks and alternatives15 risks + 6 rejected alternatives (Cython, mypyc, Nuitka, Trio, Pydantic-records, Py2-compat) + 4 future candidates (3.13 free-threaded GIL, PyPy abi3, Pyodide, mypyc compile pass)

Cross-references