Add compile-time RustPython backend with centralized backend dispatch#5986
Add compile-time RustPython backend with centralized backend dispatch#5986
Conversation
|
It would probably be better to start with an issue describing what the goal is and how you plan to approach it. Right now the size of this PR makes it completely impossible to review. It looks like right now it involves duplicating significant portions of the library, which is a red flag to me that this is going to be a long term maintenance cost. |
|
The basic idea is splitting PyO3 into front and backend with the frontend being the "user facing" and the backend targeting different Pythons - i.e. CPython and RustPython. The duplication you see is probably the current CPython-specific backend code that was moved to a new home. |
Merging this PR will degrade performance by 44.68%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | extract_str_extract_fail |
2 µs | 2.3 µs | -16.01% |
| ❌ | extract_btreeset |
17.7 ms | 32 ms | -44.68% |
| ⚡ | extract_hashset |
23.2 ms | 18.7 ms | +24.23% |
Comparing smarcd:rustpython-backend-upstream-tip (e5623b4) with main (999560a)
Footnotes
-
1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩
|
While RustPython support is laudable, this is a huge effort to embark on that will increase massively the maintenance burden for the PyO3 team. There is no obvious concensus that going this route is the way that makes most sense, e.g. RustPython has been recently looking at supporting the Python limited API. I completely second @alex that there should be clear agreement on both the goals and the solution, I am unenthusiastic about reviewing anything of this size without that achieved first. |
Summary
This PR adds a compile-time RustPython backend to PyO3 and centralizes backend selection behind backend modules instead of scattered backend-specific cfg branches.
What is included
pyo3,pyo3-ffi, andpyo3-macros-backendxtask check-backend-boundaryValidation
CPython:
cargo check -p pyo3blake3,rpds,jiter)RustPython:
cargo check --no-default-features --features macros,runtime-rustpython -p pyo3cargo test --no-default-features --features macros,runtime-rustpython -p pyo3 --test test_gcNotes
numpy-line crates.