Skip to content

Python 3.15b1 ABI support#6014

Open
ngoldbaum wants to merge 1 commit intoPyO3:mainfrom
ngoldbaum:pep-820
Open

Python 3.15b1 ABI support#6014
ngoldbaum wants to merge 1 commit intoPyO3:mainfrom
ngoldbaum:pep-820

Conversation

@ngoldbaum
Copy link
Copy Markdown
Contributor

@ngoldbaum ngoldbaum commented May 4, 2026

towards fixing #6012.

Adds support for the PEP 820 PySlot API, updates the PEP 793 implementation, and adds the critical section API to the limited API. Also fixes a small change to PyTypeObject that crept in since alpha8.

Claude helped a bit for code review and to figure out the PySlot_FUNC and the __pyo3_pymodexport macros.

Ping @bschoenmaeckers because you asked in the issue what this would look like.

Comment thread pyo3-ffi/src/slots.rs Outdated
Comment thread pyo3-ffi/src/slots.rs
/// the function with a particular signature, and a mismatch is UB.)
#[macro_export]
#[cfg(Py_3_15)]
macro_rules! PySlot_FUNC {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also possible to do this with a sealed trait but that felt magical and complicated for a tiny bit of type safety that felt questionably useful to me, in practice. Please let me know if you'd prefer I not launder an unsafe transmute inside a macro like this.

Comment thread pyo3-ffi/examples/sequential/src/module.rs
@ngoldbaum ngoldbaum marked this pull request as ready for review May 8, 2026 17:10
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 8, 2026

Merging this PR will improve performance by 12.89%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 104 untouched benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Benchmark BASE HEAD Efficiency
bench_pyclass_create 4.6 µs 4.1 µs +12.89%

Comparing ngoldbaum:pep-820 (117205b) with main (f57bda7)

Open in CodSpeed

Footnotes

  1. 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.

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

ngoldbaum commented May 8, 2026

I added 3.15 and 3.15t CI to the PR CI builds and the new CI is passing. I just rebased and squashed to get a better coverage report. (EDIT: I guess it makes sense the coverage CI is failing, given the new untested FFI definitions)

That said, this is definitely ready for review. Please let me know if you'd prefer I do this in smaller chunks.

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