Imre: progress from Astral
Imre is Astral's experimental ahead-of-time compiler for typed Python, written in Rust. It turns a
closed, statically typed program into a native executable that runs without a Python installation. Upstream is
astral-experiments/imre; everything on this page is read from main at
c5e6864ec (2026-11-25).
Compiling Imre to WebAssembly →
Imre's generated LLVM IR already compiles for wasm32-wasip1; the runtime is the work.
Runtime build errors for WASI: 556 → 10.
Milestones: 5 / 9.
An experimental .NET target →
imre build --target dotnet emits a .NET assembly through cilly. On .NET 11 it beats CPython
3.14.5 on 7 of 10 workloads, up to 7.32× (luhn_4x (scaled)).
Activity
3 authors; Charlie Marsh wrote 7,839 of 7,843 commitsCommits per day (UTC author date)
Per ISO week: 2026-W42: 1 · 2026-W43: 932 · 2026-W44: 1,069 · 2026-W45: 3,033 · 2026-W46: 2,374 · 2026-W47: 429 · 2026-W48: 5
Merged PR number over time
7,727 first-parent commits end in “(#NNNN)”, from #1 to #9206.
Lines of Rust per crate
Newline counts of every *.rs file under crates/, at the first commit of each week and month (* = HEAD). The first code import used the crate names relar-compiler and relar-runtime.
How Imre compiles
docs/design.md, docs/subset.mdImre compiles every executable Python body ahead of time. Within one compiled function, operations on values whose types are proved (exact ints, floats, fixed classes, concrete containers) become native LLVM instructions, while operations on Python objects call the Rust runtime ('boxed native code that calls the runtime'). There is no interpreter fallback: the earlier Python source evaluator was retired.
- Parse with Ruff's parser (docs/design.md:7).
- Check: Imre resolves imports, signatures and class layouts across the whole program and asks ty for semantic queries (docs/design.md:7).
- Lower to a typed, representation-checked IR; range analysis proves machine-word arithmetic and borrow analysis removes retains (docs/design.md:9).
- Emit LLVM IR as text, split per source module so unchanged modules are reused (docs/design.md:11).
- Compile with Clang (
-O<n> -c -x ir -) and link againstlibimre_runtime.a, a Rust static library (crates/imre-compiler/src/build_cache.rs:386-387).
Native-only admission. Since #9204 (2026-11-25, one commit before HEAD), `imre check`/`imre build` accept only fixed native lowering; programs that need registered Python frames, a runtime module launcher or the general Python object runtime are rejected, with no override. (docs/native-only.md:3-8)
The value word
An int is one machine word, struct Int(usize). Small values are stored inline as
(v << 1) | 1; anything else is a pointer to a reference-counted BigInt
(crates/imre-runtime/src/lib.rs:76-99, docs/subset.md:1476). The compiler's IR passes these words as i64.
CPython stdlib test scorecard
CPython 3.14.5 · Linux x86-64 · 45 familiesA test is paired when stock CPython passes it and Imre passes it at both -O0 and -O3.
13,081 of 15,183 stock Linux passes are paired (86.2%; 584 short of 90%).
Against all 16,225 original tests it is 13,179 (81.23%). (README.md:263, README.md:247)
Headline percentage, every README revision
Denominators grow as families are added (13,328 → 16,225 originals). The sentence last changed on 2026-11-16 (7b11a4e8a).
Per family
| family | originals | stock pass | paired | % | |
|---|---|---|---|---|---|
argparse | 1,893 | 1,893 | 1,887 | 99.7% | |
importlib | 1,345 | 1,328 | 432 | 32.5% | |
unittest | 1,090 | 1,088 | 1,054 | 96.9% | |
datetime | 1,098 | 1,066 | 1,029 | 96.5% | |
io | 1,038 | 1,010 | 954 | 94.5% | |
pathlib | 1,369 | 963 | 947 | 98.3% | |
typing | 712 | 712 | 710 | 99.7% | |
collections | 659 | 655 | 638 | 97.4% | |
socket | 746 | 614 | 104 | 16.9% | |
os | 579 | 486 | 469 | 96.5% | |
inspect | 362 | 362 | 264 | 72.9% | |
zipfile | 383 | 343 | 336 | 98.0% | |
configparser | 344 | 339 | 339 | 100.0% | |
functools | 329 | 325 | 316 | 97.2% | |
subprocess | 353 | 309 | 297 | 96.1% | |
dataclasses | 276 | 276 | 273 | 98.9% | |
logging | 272 | 268 | 220 | 82.1% | |
zoneinfo | 261 | 233 | 229 | 98.3% | |
threading | 228 | 223 | 97 | 43.5% | |
json | 216 | 213 | 205 | 96.2% | |
warnings | 187 | 181 | 177 | 97.8% | |
weakref | 183 | 179 | 168 | 93.9% | |
ssl | 195 | 178 | 66 | 37.1% | |
shutil | 223 | 173 | 171 | 98.8% | |
urllib | 178 | 173 | 173 | 100.0% | |
re | 165 | 161 | 145 | 90.1% | |
contextlib | 149 | 149 | 149 | 100.0% | |
types | 141 | 139 | 134 | 96.4% | |
itertools | 138 | 132 | 110 | 83.3% | |
tokenize | 130 | 130 | 127 | 97.7% | |
csv | 128 | 124 | 122 | 98.4% | |
tempfile | 118 | 112 | 110 | 98.2% | |
math | 89 | 86 | 83 | 96.5% | |
copy | 81 | 81 | 81 | 100.0% | |
gzip | 75 | 75 | 74 | 98.7% | |
hashlib | 82 | 69 | 67 | 97.1% | |
textwrap | 68 | 68 | 68 | 100.0% | |
fractions | 50 | 50 | 50 | 100.0% | |
uuid | 120 | 48 | 47 | 97.9% | |
struct | 43 | 43 | 34 | 79.1% | |
base64 | 41 | 41 | 40 | 97.6% | |
fnmatch | 24 | 24 | 24 | 100.0% | |
glob | 24 | 22 | 22 | 100.0% | |
netrc | 23 | 22 | 22 | 100.0% | |
tomllib | 17 | 17 | 17 | 100.0% |
From benchmarks/cpython_stdlib/full/frozen-stock-intersection-8818.tsv.
Caveats. The 86.2% figure is a historical mixed-revision ledger. The README's own pinned scorecard at revision 95908fb0 (README.md:111-181) credits only 666 verified pairs of 16,225 originals, because only configparser, dataclasses, fnmatch and part of json were re-run at that pin. Per-family stock skips and errors are not in the TSV or README: only the totals (1,024 skips, 7 errors, 11 unregistered) are published. stockNotPass = originals - stockPass lumps skips, errors and unregistered tests together. 'paired' = CPython 3.14.5 passed the original test and Imre passed it at both -O0 and -O3 (README.md:249-250).
Feature matrix
docs/subset.md, docs/stdlib.md, README.mdLanguage
| area | feature | status | source |
|---|---|---|---|
| Numbers | int (arbitrary precision; tagged word in [-2**62, 2**62), num-bigint outside) Checked arithmetic promotes/demotes | native | docs/subset.md:40, docs/subset.md:1476 |
| float (IEEE binary64) | native | docs/subset.md:41, docs/subset.md:605 | |
| bool as its own exact type | native | docs/subset.md:56 | |
| Text | str (immutable UTF-8): slicing, split, join, replace, find, format | native | docs/subset.md:47 |
| f-strings, str.format, % formatting Bounded format specs | native | docs/subset.md:47, docs/subset.md:742 | |
| bytes | native | docs/subset.md:49 | |
| Containers | list[T] with one exact element type No slice assignment/deletion | native | docs/subset.md:42 |
| dict[K, V] with exact key types Keys: int, str, StrEnum, bytes, Path, immutable tuples | native | docs/subset.md:43 | |
| set[T] | native | docs/subset.md:44 | |
| Fixed tuples (one type per position) | native | docs/subset.md:46 | |
| collections.deque[T] Native ring buffer | native | docs/subset.md:1304 | |
| Types | T | None and str | bytes Bounded unions only | native | docs/subset.md:36 |
| Any, unrestricted unions, untyped objects in native storage ty checks first; Imre then enforces exact types | unsupported | docs/subset.md:56 | |
| enum.StrEnum and typing.Literal strings Members stored as integer tags | native | docs/subset.md:1147 | |
| Functions | Exact signatures: positional/keyword, positional-only, keyword-only, scalar defaults | native | docs/subset.md:35 |
| Unannotated parameters inferred from defaults and concrete calls | native | docs/subset.md:66 | |
| Direct and mutual recursion Needs resolved signatures | native | docs/subset.md:35, README.md:99 | |
| Callable values, bound methods, noncapturing lambdas | native | docs/subset.md:35, docs/subset.md:191 | |
| functools.cache / lru_cache / partial | native | docs/subset.md:9-19, docs/subset.md:21-28 | |
| Closures that need Python cells Compiler can request a registered frame; see native-only admission | boxed | docs/design.md:36-40 | |
| Calling a runtime-selected callable (e.g. handlers[key](value)) Looked up and invoked through the Python runtime inside compiled code | boxed | docs/design.md:23, docs/design.md:55 | |
| Arbitrary decorators Excluded from fixed layouts | unsupported | docs/subset.md:62 | |
| General generator functions Excluded from fixed layouts; generator expressions consumed immediately are lowered | unsupported | docs/subset.md:62, docs/subset.md:238 | |
| Open-ended argument expansion, untyped *args | unsupported | docs/subset.md:62 | |
| Classes | Fixed-layout classes, dataclasses (incl. frozen), properties, class/static methods | native | docs/subset.md:37 |
| Single concrete base class inheritance | native | docs/subset.md:1246 | |
| @imre.struct immutable value structs stored inline in lists | native | docs/subset.md:1250-1252, README.md:429-433 | |
| Reflection and dynamic attributes getattr over a known set of field names compiles | unsupported | docs/subset.md:62, README.md:90-91 | |
| Control flow | if/while/for/else, break/continue, assert | native | docs/subset.md:38 |
| Structural pattern matching (match/case) | native | docs/subset.md:1116 | |
| Assignment expressions (:=) | native | docs/subset.md:570 | |
| Exceptions: try/except/else/finally, raise Sealed builtin Exception family | native | docs/subset.md:38, docs/subset.md:1498 | |
| with (builtin file / workspace context managers) | native | docs/subset.md:38 | |
| Comprehensions | List/dict/set comprehensions | native | docs/subset.md:45 |
| Lazy pipelines: map/filter/zip/enumerate/reversed/generator expressions Lowered into native control flow at the consumer | native | docs/subset.md:238 | |
| Async | Typed coroutines, await, asyncio.TaskGroup / gather / Semaphore Subprocess-backed work | native | docs/subset.md:1747 |
| Async generator feeding an async comprehension | native | README.md:100, docs/subset.md:62 | |
| Concurrency | Threads sharing Python objects Compiles but raises NotImplementedError at Thread.start() | unsupported | docs/subset.md:1730-1734 |
| Modules | Closed first-party import graph (absolute, from, relative imports) No import cycles | native | docs/subset.md:32-33 |
| Modules selected by name at runtime (--include-module) Links source for a runtime module loader; a fully typed entry rejects it | boxed | docs/subset.md:641 | |
| exec / eval / runpy on source chosen at runtime Reported before linking | unsupported | docs/design.md:63 | |
| Values | Inferred results in Python object storage | boxed | docs/subset.md:510 |
| Regex | re.compile / re.search on fixed literal patterns | native | docs/subset.md:48, docs/subset.md:441 |
| Literal lookaheads and fixed-width lookbehinds Uses the boxed matcher | boxed | docs/subset.md:485 | |
| Extensions | C extensions rebuilt against Imre's Python.h Wheels carry a static archive plus typed signatures | native | docs/design.md:73, README.md:414-416 |
Standard library modules (194)
native 84 · boxed 3 · unknown 43 · unsupported 64. Hover a module for its API note.
Statuses are partly inferred: docs/stdlib.md calls this import inventory historical and does not say native vs boxed per module, so modules are classified by the wording of their API note. Some modules listed as rejected imports have passing suites in the README scorecard.
CLI
| command | does | source |
|---|---|---|
imre build (SOURCE.py | -m MODULE) [-o OUTPUT] | Compile to a native executable named after the source file | crates/imre-compiler/src/main.rs:39, crates/imre-compiler/src/main.rs:56 |
imre run SOURCE.py [-- ARGS] | Compile (cached) and run; arguments after -- go to the program | crates/imre-compiler/src/main.rs:40, README.md:506 |
imre check SOURCE.py [--watch] | Type-check and validate without linking; --watch reports each revision | crates/imre-compiler/src/main.rs:33, README.md:510 |
imre [-c CODE | -m MODULE | SCRIPT] | Python-compatible launcher: compiles and runs as native code; sys.implementation.name == 'imre'; discoverable by uv | crates/imre-compiler/src/main.rs:34, README.md:53-64 |
imre wheel PROJECT [--out-dir DIR] [--overlay DIR] [--python PYTHON] | Build a native-extension wheel | crates/imre-compiler/src/main.rs:38, crates/imre-compiler/src/main.rs:114-115 |
imre extension-header | Print Imre's Python.h (C API header for extensions) | crates/imre-compiler/src/main.rs:36, crates/imre-compiler/src/main.rs:117-122 |
imre build-target [--output-dir DIR] | Report the target description (target.json) used by extension builds | crates/imre-compiler/src/main.rs:37, .github/workflows/build-release-binaries.yml:89-90 |
Release targets
| triple | built | archive |
|---|---|---|
x86_64-unknown-linux-gnu | every release | Clang 18 + LLD 18 toolchain, libimre_runtime.a, libimre_runtime_jemalloc.a, bundled stdlib zip and O0/O3 provider archives |
aarch64-unknown-linux-gnu | every release | Same as x86-64 Linux; jemalloc built for up to 64 KiB pages |
aarch64-apple-darwin | only with include_macos | imre + libimre_runtime.a only (uses Apple Clang); included only when include_macos is set |
Optimization levels -O0, -O1, -O2, -O3 (default -O3). --whole-program optimizes all modules together; default splits LLVM per source module for incremental reuse.
Allocators: system (default), jemalloc (Linux).
Published benchmarks
benchmarks/Application CLIs: median elapsed ms, one AMD EPYC Milan vCPU, warm caches, includes process startup
| workload | median ms | vs CPython | Imre / Rust |
|---|---|---|---|
| uv download catalog | 153.9 103.5 2,884.0 | 18.7× | 1.49× |
| Source search | 54.5 48.1 187.5 | 3.4× | 1.13× |
| Wheel verification | 36.9 22.6 155.2 | 4.2× | 1.63× |
| Road graph load | 61.2 60.9 531.1 | 8.7× | 1.0× |
| Road routing | 102.7 92.6 1,926.9 | 18.8× | 1.11× |
| Conformance report | 29.9 21.9 255.9 | 8.6× | 1.37× |
benchmarks/applications/README.md:15-34. Speedups derived from the published medians.
HTTP throughput, 8 concurrent clients, median of rounds (requests/s)
| Frozen Flask on Imre 0.1.5 | 9,521 |
| Rust/Hyper (single-threaded) | 9,558 |
| Stock Flask on CPython (Werkzeug) | 1,028 |
benchmarks/applications/README.md:38-40; README.md:24-32
Original runtime suite (2026-10-28)
| workload | median ms | vs CPython |
|---|---|---|
| Inventory (repeated) | 41.81 27.36 90.37 | 2.2× |
| Inventory (distinct) | 72.64 48.90 121.16 | 1.7× |
| Base45 decode | 16.88 9.73 206.27 | 12.2× |
| Luhn checksum | 13.73 5.71 157.62 | 11.5× |
| Telemetry report | 16.49 10.31 128.03 | 7.8× |
| Conformance report | 48.51 29.67 290.33 | 6.0× |