Skip to content

Python 3.15b1 ABI support#6014

Draft
ngoldbaum wants to merge 10 commits intoPyO3:mainfrom
ngoldbaum:pep-820
Draft

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

Conversation

@ngoldbaum
Copy link
Copy Markdown
Contributor

@ngoldbaum ngoldbaum commented May 4, 2026

Fixes #6012. Based on a version of CPython where I manually merged two open PRs. This is not mergeable until 3.15.0b1 actually releases to Github actions.

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
self as *const Self as *const c_void,
other as *const Self as *const c_void,
std::mem::size_of::<Self>(),
) == 0
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.

Should maybe check each field individually? I couldn't automatically derive this because of the unions.

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.

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.

Supporting 3.15.0b1 and finishing off support for the 3.15 ABI

1 participant