Skip to content

add PyO3 FFI checks to the suite - #55

Open
davidhewitt wants to merge 2 commits into
pypy:mainfrom
davidhewitt:patch-1
Open

add PyO3 FFI checks to the suite#55
davidhewitt wants to merge 2 commits into
pypy:mainfrom
davidhewitt:patch-1

Conversation

@davidhewitt

Copy link
Copy Markdown
Contributor

I added nox -s ffi-check job from PyO3 which runs some sanity checks that PyO3's FFI definitions match what PyPy is exporting from its headers.

NB from running this locally I think I observed that PyPy needs to implement PEP 623.

@mattip

Copy link
Copy Markdown
Member

I opened PyO3/pyo3#6345 about the c_int failures. The missing _PyInterpreterFrame is typedefed in frameobject.h, i wonder why it was not found

@davidhewitt

Copy link
Copy Markdown
ContributorAuthor

I opened PyO3/pyo3#6374 which should address both issues, once merged we'll see what the next issues are 👀

@davidhewitt

Copy link
Copy Markdown
ContributorAuthor

Ok we're now at a point where we see the wstr fields removed in PEP 623, I guess that's an action on PyPy.

Plus I think CPython changed the PyObject struct to have a union for one field, PyPy might not care about that in which case we can action that on the PyO3 side.

@mattip

Copy link
Copy Markdown
Member

I am working on the wstr change, thanks for pointing it out. Then I will think about the union. We need to be able to parse the struct with pycparser, I don't know if it will handle that and if not how we can have an internal/external declaration. I would like to move to 100% CPython compatibility for the limited API functions and structs.

@bschoenmaeckers

Copy link
Copy Markdown

I would like to move to 100% CPython compatibility for the limited API functions and structs.

This is cool, as RustPython is also aiming to support CPython abi3t!

@davidhewitt

Copy link
Copy Markdown
ContributorAuthor

I would like to move to 100% CPython compatibility for the limited API functions and structs.

This would be nice, you should definitely check out 3.15's abi3t which removes the layout of the PyObject struct from the ABI. I wonder if abi3t would allow PyPy to do more of the optimizations which e.g. HPy also makes possible.

(I realise that PyPy probably has a fair bit of work to catch up with 3.15, however...)

@bschoenmaeckers

Copy link
Copy Markdown

I'm wondering if it's possible to backport abi3t to previous versions. But this probably lacks essential functions

@mattip

Copy link
Copy Markdown
Member

I refactored to remove the wstr field, thanks for pointing out 3.12 removed it. As for the anonymous structure, that is a deeper problem with the PyPy RPython infrastructure. We need to be able to parse the struct definition with internal tools, they cannot handle a union. Is there a way to simplify that from the PyO3 side?

@mattip

Copy link
Copy Markdown
Member

closing/reopening to retrigger CI

@mattipmattip closed this Sep 3, 2026
@mattipmattip reopened this Sep 3, 2026
@mattip

Copy link
Copy Markdown
Member

I also merged the PR to not mangle names of all the limited-api functions. This will undoubtedly mess up the PyO3 special-casing of function names.

@davidhewitt

Copy link
Copy Markdown
ContributorAuthor

PyO3/pyo3#6389 will hopefully catch up PyO3 to the next phase of changes here.

Sign up for freeto 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.

3 participants

@davidhewitt@mattip@bschoenmaeckers