Repository navigation
Feat: TypedPython fixed-layout classes (N-11) - #124
Merged
Merged
Conversation
ClassDecl (user-written __slots__ = annotated fields, trivial_init), Is (identity, e.g. x is None via Const(None, OBJ)), IsExact (type(x) is C), CheckExact (exact-type proof that deopts, pure-only), FieldGet (slot read through the member descriptor captured at init; not an effect), FieldSet (an effect), New (allocate-and-fill for a trivial __init__; not an effect), and Param.cls/optional for exact-type entry guards. Runtime API for capturing slots, reading/writing them and allocating fixed objects. Refs #41
…s after init (N-11)
Member
Author
|
Before/after measurement of the per-access class checks (4987883 vs 11e52af), interleaved: each pair runs compiled(before) and compiled(after) in alternating order, plus CPython. 11 pairs per benchmark, default sizes, macOS arm64, CPython 3.14.7. Load was 9–13, so read the ratios, not absolute times.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #123
Features added
ClassDecl(only for user-written__slots__),None,is/is not, class-typed parameters (C,C | None),FieldGet/FieldSet,Newfor a trivial__init__. A rejected class gets a reason inModule.skipped.Newarity, exact-type proof for every field access (the accepted forms are listed in theverify.pydocstring), purity/deopt, ownership.__dict__, member descriptors made for exactly that class). Each slot access checks the exact type andtp_version_tag; eachNewchecks the global through a module-dict watcher, or a dict lookup when no watcher id is free. A mismatch takes the generic path (impure functions) or deopts (pure functions).Param.clsguards also run on direct C-to-C calls.Documentation corrected
ir.py: class-param calls can deopt.runtime/API.md: the new helpers.Tests added: front end, verifier, cgen classes, and 17 class-change scenarios (each compared against the interpreted module, crash cases in subprocesses), plus ASan/UBSan runs. Red and mutation results are in the branch commits' reports.
Benchmark: binary-trees'
Nodedeclares__slots__;run.pyadds aCPython (no __slots__)column, and ininterleavedper-pair no-slots times.makeandcheckcompile;run.py verifyagrees across all five benchmarks.Verification (local, macOS arm64, CPython 3.14.7): the full TypedPython suite gives 934 passed, 3 skipped, EXIT=0.
Pending: the interleaved before/after measurement of the per-access checks (binary-trees and nbody) is waiting for a quiet machine (load 20–40). Results will be posted here.