You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 34b9e79
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/SPEC.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1307,7 +1307,7 @@ All in `PM/commonTest`, so they run wherever the interpreter loads.
1307
1307
impure one; `ValueError` with the same message; augmented forms; INT and object operands; `bool` and
1308
1308
float operands skipped or `TypeError`. `Status: implemented`.
1309
1309
-**N-17** TypedPython AOT mode: a standalone build with no interpreter (#443; INTENT §1.4, maintainer
1310
-
decision 2026-11-16). `Status: planned, not implemented; design first`. A check-only mode exists (`python -m typedpython aot-check <entry.py>`): it builds nothing and reports every construct an AOT build would refuse, as an error or as pending with its tier (K, O, S or T), and a ready status per function (#446; agent proposal, not owner-confirmed). A first AOT build step exists (`python -m typedpython aot-build`): single-module programs with an `if __name__ == "__main__"` entry, scalar functions, native `list[float]` / `list[int]` values (counted, passed, returned and aliased by name), fixed tuples of scalars returned and unpacked, `print` with f-strings (`{e}` and `{e:.Nf}`), the conditional expression, `abs`, `min` and `max`, `len(sys.argv)`, and module constants (`NAME = <constant expression>`, also annotated `int`, `float` or `bool`), strict integers (an operation not proved inside 64 bits is `aot/int-unproven`, and so is `int(sys.argv[i])`: no run-time path differs from CPython), differential-tested against CPython (a variant of nbody with its size fixed in the source builds and prints what CPython prints; nbody, spectral_norm and fannkuch as they are, are refused only for `aot/int-unproven`); the front end and verifier read the file itself in an AOT mode that is off by default (#448, #451; agent proposal, not owner-confirmed).
1310
+
decision 2026-11-16). `Status: planned, not implemented; design first`. A check-only mode exists (`python -m typedpython aot-check <entry.py>`): it builds nothing and reports every construct an AOT build would refuse, as an error or as pending with its tier (K, O, S or T), and a ready status per function (#446; agent proposal, not owner-confirmed). A first AOT build step exists (`python -m typedpython aot-build`): single-module programs with an `if __name__ == "__main__"` entry, scalar functions, native `list[float]` / `list[int]` values (counted, passed, returned and aliased by name), fixed tuples of scalars returned and unpacked, `print` with f-strings (`{e}` and `{e:.Nf}`), the conditional expression, `abs`, `min` and `max`, `len(sys.argv)`, and module constants (`NAME = <constant expression>`, also annotated `int`, `float` or `bool`), strict integers (an operation not proved inside 64 bits is `aot/int-unproven`, and so is `int(sys.argv[i])`: no run-time path differs from CPython), differential-tested against CPython (a variant of nbody with its size fixed in the source builds and prints what CPython prints; nbody, spectral_norm and fannkuch as they are, are refused only for `aot/int-unproven`); the front end and verifier read the file itself in an AOT mode that is off by default (#448, #451; agent proposal, not owner-confirmed). The library output exists (`python -m typedpython aot-lib <module.py> --export f,g --prefix <p> -o <dir>`): it writes a shared library, a C header and a JSON description of the same signatures (exports with int, float, bool and list arguments as counted handles, results through out pointers, a thread-local `<p>_last_error`, no library-wide lock), and is tested through a C-ABI consumer that compares every export with CPython (#455; owner decision D5 for its existence, shape per leader decisions of 2026-11-16, not owner-confirmed).
1311
1311
-**Selection.** Opt-in per build; the default mode (N-1 to N-16, interpreted fallback) is unchanged.
1312
1312
-**Acceptance.** The whole program must pass the verifier. Every construct that the default mode would
1313
1313
leave interpreted or deopt from (unknown calls, unproven bounds or overflow without a compiled
|`int` not proved inside i64 | not exportable in a signature (compile error naming the parameter); the export must narrow it or return it as a string ||
312
312
|`str`| pointer and length of UTF-8 bytes; an argument is borrowed for the call, a result is owned by the caller and released with `<prefix>_free`|`String`, copied at the boundary |
313
-
|`list[float]` / `list[int]`argument | pointer and length, borrowed for the call|`DoubleArray` / `LongArray`, pinned or copied as the platform requires|
313
+
|`list[float]` / `list[int]`, as an argument and as a result | an opaque counted handle (`<prefix>_f64_list`, `<prefix>_i64_list`) made and read through exported list functions (`_new`, `_len`, `_data`, `_retain`, `_release`); an argument is borrowed for the call, a returned handle is owned by the caller | a class holding the handle, with `DoubleArray` / `LongArray` copied from or to the `_data` address as the app needs|
314
314
| an instance of a compiled class, or any other container | an opaque handle (a counted reference) with `<prefix>_release(handle)`| a Kotlin class holding the handle, released deterministically (`close`) with a cleaner as a safety net |
315
315
|`None` result |`void`|`Unit`|
316
316
317
+
The list row is a leader decision of 2026-11-16, not owner-confirmed. Reason: an AOT list carries a 16-byte
318
+
header (count and length) before its elements, so a foreign array cannot be passed as it is; a handle
319
+
also keeps Python's list identity across calls (a function that returns its argument returns the same list,
320
+
and two parameters may be one list, as two names are in the source).
321
+
317
322
Errors: every exported function returns a status; on failure the exception's class name and message
318
323
are read with `<prefix>_last_error` on the same thread, and the generated Kotlin wrapper throws a
319
324
Kotlin exception carrying both. Nothing unwinds across the boundary.
320
325
321
-
Threads: an exported function may be called from any Kotlin thread; the runtime's per-thread state is
322
-
created on first use. Two Kotlin threads calling into the library at once are two threads of the
323
-
program in the sense of section 7, so objects reachable from handles and globals are "shared" for the
324
-
thread-escape analysis even before tier T exists. Until that analysis exists, a library whose exports
325
-
can reach shared mutable state takes one library lock around each exported call (correct, not
326
-
parallel); this is the conservative first step and is stated in the generated header.
326
+
Threads (leader decision 2026-11-16, not owner-confirmed; the library output is owner decision D5):
327
+
there is no library-wide lock and TypedPython has no GIL-like single lock. An exported function may be
328
+
called from any Kotlin thread and from several at once, so exported functions are reentrant. The error
329
+
record behind `<prefix>_last_error` is thread-local. List counts are atomic in a library build (and stay
330
+
non-atomic in an executable build). Module-level mutable state is refused for a library (`aot/library-state`):
331
+
tier K has none, since module constants are folded at compile time and a function that assigns a
332
+
module-level name makes a local. Concurrent writes to the elements of one list from several threads are the
333
+
caller's responsibility, exactly as with a Kotlin array, and the generated header says so. This replaces the
334
+
earlier proposal of one library lock around each exported call.
327
335
328
336
### 8.3 Kotlin calling Python (the downcall)
329
337
@@ -444,6 +452,8 @@ no behaviour and reports every construct of a program that would be an AOT compi
444
452
own.
445
453
-`lru_cache` is the second object-heavy benchmark.
446
454
- Packaging of the library artefact stays open: it waits for the same owner decision as #25 step 3.
455
+
- Verifying the Kotlin downcall inside a GraalVM native image is issue #456 and a completion condition of tier K
456
+
(leader, 2026-11-16, not owner-confirmed; AGENTS.md 13 applies to the library as it does to upcalls).
0 commit comments