compile: --target 3.11 emission switch; PyPy is the fastest measured host - #7
Merged
Conversation
…host Emitted code needed Python 3.12 for exactly one construct: f-string holes carrying nested same-quote string literals or backslashes (PEP 701). `pyfun compile --target 3.11` rewrites exactly those f-strings into equivalent "template".format(args...) calls (src/python_emitter/py311.rs, applied by emit_for on a clone of the IR, single-file and project paths); clean f-strings stay f-strings, so output only changes where it must. The unsafe check renders each hole through the emitter itself, so it is exact. The switch unlocks PyPy (3.11 ceiling), which the same-day verification crowns the best host measured for emitted Pyfun: 1.5-3.6x faster than CPython 3.14 cold across the bench suite, byte-identical outputs, and none of GraalPy's ADT-allocation pathology. bench/run.py grew --target (output in bench/out-3.11/). Three new tests; INTERNALS + ROADMAP + bench README updated. Claude-Session: https://claude.ai/code/session_011PBhfjrzsUtwupYtJtzAWu
Merged
simontreanor
added a commit
that referenced
this pull request
Jul 18, 2026
Ships the --target 3.11 emission switch (PyPy support) in the published wheel. See the v0.1.1 tag and PR #7 for the feature itself. Claude-Session: https://claude.ai/code/session_011PBhfjrzsUtwupYtJtzAWu
This was referenced Jul 31, 2026
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.
The switch
Emitted Pyfun needed Python 3.12 for exactly one construct: an f-string hole carrying a nested same-quote string literal or a backslash (PEP 701).
pyfun compile --target 3.11rewrites exactly those f-strings into equivalent"template".format(args...)calls (src/python_emitter/py311.rs, applied byemit_foron a clone of the IR; single-file and project paths). Clean f-strings stay f-strings, so 3.11-target output only changes where it must, and the unsafe check renders each hole through the emitter itself, making it exact by construction. Everything else Pyfun emits is 3.10-compatible.pyfun compile <file> --target 3.11|3.12(default 3.12, help text updated)compile_targeting/project::compile_targeting(existingcompiledelegates)--target 3.11compiles intobench/out-3.11/PyPy verification (the reason the switch exists)
PyPy 7.3.23 (
pypy:3.11container) runs the 3.11-target output with byte-identical results across the smoke test and full bench suite, and it is the best host measured for emitted Pyfun, cold:GraalPy's ADT-allocation pathology does not transfer (steady ~0.4s/iter on the warmup probe), and cold PyPy beats the mypyc-compiled expr_eval figure (0.525s vs 0.824s) with zero user toolchain. Weak spot: recursion (collatz 7.36x vs PyPy's own iterative baseline, though still faster than CPython in absolute terms). Full write-up in
local/pypy-verification/(untracked by design).https://claude.ai/code/session_011PBhfjrzsUtwupYtJtzAWu