Skip to content

gh-148325: Add PyObject_GetItemData() to the limited C API and stable ABI#148324

Open
wjakob wants to merge 1 commit intopython:mainfrom
wjakob:main
Open

gh-148325: Add PyObject_GetItemData() to the limited C API and stable ABI#148324
wjakob wants to merge 1 commit intopython:mainfrom
wjakob:main

Conversation

@wjakob
Copy link
Copy Markdown
Contributor

@wjakob wjakob commented Apr 10, 2026

This PR promotes PyObject_GetItemData() and PyObject_GetItemData_DuringGC() to the stable ABI (analogous to PyObject_GetTypeData() and PyObject_GetTypeData_DuringGC() that are already in the stable ABI).

The function PyObject_GetItemData() is needed to access the entries of variable sized objects (PyVarObject).

Why this change?

  • PyVarObject becomes opaque in abi3t.
  • nanobind (used by large-scale ML and compiler projects like Google's JAX, Apple's MLX, LLVM, MLIR, ...) uses a variable sized function object
  • Ergo: without access to PyObject_GetItemData(), nanobind cannot run on abi3t.

I am urgently (⚠️) trying to still get this into Python 3.15.

@vstinner @ngoldbaum @encukou


📚 Documentation preview 📚: https://cpython-previews--148324.org.readthedocs.build/

@wjakob wjakob requested review from a team, ZeroIntensity and encukou as code owners April 10, 2026 07:30
@wjakob wjakob changed the title gh-145921: Add PyObject_GetItemData to the limited C API and stable ABI gh-148325: Add PyObject_GetItemData to the limited C API and stable ABI Apr 10, 2026
…able ABI

Move PyObject_GetItemData and PyObject_GetItemData_DuringGC from the
unstable CPython API (Include/cpython/object.h) to the limited C API
(Include/object.h), gated on Py_LIMITED_API >= 3.15, and declare them
as part of the stable ABI in Misc/stable_abi.toml.
@wjakob wjakob changed the title gh-148325: Add PyObject_GetItemData to the limited C API and stable ABI gh-148325: Add PyObject_GetItemData() to the limited C API and stable ABI Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant