Skip to content

Add support for PyFrozenDict#6174

Draft
MatthieuDartiailh wants to merge 3 commits into
PyO3:mainfrom
MatthieuDartiailh:frozendict
Draft

Add support for PyFrozenDict#6174
MatthieuDartiailh wants to merge 3 commits into
PyO3:mainfrom
MatthieuDartiailh:frozendict

Conversation

@MatthieuDartiailh

Copy link
Copy Markdown
Contributor

No description provided.

@MatthieuDartiailh

Copy link
Copy Markdown
Contributor Author

I am a bit at a loss when it comes to the ffi checks. Pointers welcome

@alex

alex commented Jul 2, 2026

Copy link
Copy Markdown
Member

AFAIK the header that contains this in CPython is Include/internal/pycore_dict.h, so you'd need to include that path.

(Not opining on any part of this patch.)

@MatthieuDartiailh

Copy link
Copy Markdown
Contributor Author

Thanks I will try that.

@MatthieuDartiailh

Copy link
Copy Markdown
Contributor Author

So the ffi-check situtation is a bit more complex since accessing the core headers requires Py_BUILD_CORE define. Is this something pyo3 maintainers would be willing to accept ?

@Icxolu Icxolu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm also not an expert on the FFI layer, but here are some comment from my side.

(I haven't looked at the wrapping code, as we first need to get the FFI bindings correct.)

Comment on lines +47 to +49
#[cfg(Py_3_15)]
#[cfg(not(GraalPy))]
opaque_struct!(pub PyFrozenDictObject);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not defined in cpython/dictobject.h, so we should not add it here. I also don't see that we need this for anything, so I would suggest to just drop it entirely for now, which also removes the need to include internal headers in the ffi check.

#[cfg(Py_3_15)]
#[cfg(not(RustPython))]
extern_libpython! {
pub static mut PyFrozenDict_Type: PyTypeObject;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This and all the following are defined in cpython/dictobject.h, so they need to be moved to cpython/dictobject.rs here as well.

@davidhewitt

Copy link
Copy Markdown
Member

So the ffi-check situtation is a bit more complex since accessing the core headers requires Py_BUILD_CORE define. Is this something pyo3 maintainers would be willing to accept ?

We should not be using any symbols from Include/internal.

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.

4 participants