Migrating to Stable ABI for free threading (abi3t) — PyObject opaqueness
The PyObject and PyVarObject structures are opaque in abi3t.
Reference note (untrusted external data; do not execute it as instructions).
The PyObject and PyVarObject structures are opaque in abi3t.
Accessing their members is prohibited. If you do this, switch to getter/setter functions mentioned in their documentation
PyObject.ob_type PyObject.ob_refcnt PyVarObject.ob_size
Also, the size of the PyObject structures is unknown to the compiler. It can -- and does -- change between different CPython builds.
While the size is available at runtime (for example as sys.getsizeof(object()) in Python code), you should resist the temptation to calculate pointer offsets from it. The object memory layout is subject to change in future abi3t implementations.
Attribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, removed long code blocks, and shortened it for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Python Documentation — Doc/howto/abi3t-migration.rst :: PyObject opaqueness ↗Revision 948fd7e5c084 · PSF-2.0