Repository navigation
feat(cpython): opt-in native code (cpython-native) - #2544
Merged
Merged
Conversation
Compile the CPython snapshot to native code for the build target instead of Pulley when the cpython-native feature is on. Claude-Session: https://claude.ai/code/session_01Ke1iW2hQi9VXioZi1avPaW
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | fbb14d4 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 05:40 AM |
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.
What changed
New opt-in feature
cpython-native(bashkit and bashkit-cli; companion crate featurenative). With it,build.rscompiles the CPython snapshot to machine code for Cargo'sTARGET(baseline ISA, so the binary runs on any CPU of that architecture) instead of Pulley bytecode. Defaultcpythonis unchanged.Why
Pulley interprets every guest instruction. Native code makes calls 4-10x faster for users who can allow executable memory. Nothing is compiled at run time with either option.
Before
Pulley only:
print(1)~3.7 ms,import http.client461 ms,fib(20)69 ms per call. CPython test suite 17 s.After
With
cpython-native:print(1)~0.95 ms,import http.client34 ms,fib(20)6.4 ms. First load in a process ~47 ms (native code cannot run from the read-only static, so the module is copied);CPython::warm_up()moves it to startup. CPython test suite 112/112 pass in 3 s. CI runs the CPython suites on the native build too.Risk
Medium, opt-in only. Native mode runs Cranelift-generated machine code, so a code-generation bug could break the wasm sandbox (TM-PY-CPY-011). Memory config is identical to Pulley (1 GiB reservation, 64 KiB guard, explicit bounds checks). Default builds run no generated machine code.
Checklist
cargo test -p bashkit --features cpython-native --lib --test integration -- cpythoncargo clippy -p bashkit-cpython-wasm --features native --all-targets -- -D warnings,cargo clippy -p bashkit --features cpython-nativecargo fmt --checkcpython.md,docs/cli.md), knowledge (cpython-wasm.md, threat model, log)Generated by Claude Code