Skip to content

native: typed emit and pyfun build for projects - #158

Merged
simontreanor merged 2 commits into
mainfrom
lowering/native-typed-projects
Sep 28, 2026
Merged

simontreanor merged 2 commits into
mainfrom
lowering/native-typed-projects

Conversation

@simontreanor

Copy link
Copy Markdown
Owner

Extends #155/#156 from single files to multi-file projects.

  • Typed emit for projects: project::compile_with already type-checks each module in topological order (for float literals and codecs); in native mode it now also keeps each module's resolved types and hands them to lower_in_project, so every module's top-level functions get annotations. Option/Result spell through the classes a project imports from _pyfun_rt (def lookup(key: int) -> Some | None_:).
  • pyfun build --native for projects: every module is written to <dir>, all but _pyfun_rt.py go through one mypyc invocation, and the runtime stays Python (the compiled modules import it like any other module). __main__.py imports the entry module.
  • CI: native-bench gains a step that builds examples/modules natively on Linux and diffs its output against pyfun run.

Locally (Windows): the project passes mypy and reaches mypyc's build_ext for a shared extension of all three modules, stopping only for the missing MSVC Build Tools. The Linux run is in this PR's checks. DESIGN §5.6, ROADMAP and the README section updated.

Project lowering now receives each module's resolved types (already computed
in the per-module pass for float literals), so every module's top-level
functions are annotated in native mode, and Option/Result spell through the
classes a project imports from _pyfun_rt. pyfun build --native accepts a
project: every module is built by mypyc in one go and the shared
_pyfun_rt.py stays Python. native-bench gains a step that builds
examples/modules natively and diffs its output against pyfun run.
@simontreanor
simontreanor merged commit 8f6f8f3 into main Sep 28, 2026
21 checks passed
@simontreanor
simontreanor deleted the lowering/native-typed-projects branch September 28, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant