Skip to content

Expose Py_SIZE, Py_IS_TYPE, Py_SET_SIZE as functions in the Stable ABIย #139165

@encukou

Description

@encukou

Feature or enhancement

Py_SIZE & Py_SET_SIZE have issues -- I wish ob_size was much less public than it is -- but they can be used correctly and don't currently have good alternatives for some use cases.
Also, they're available as static inline functions when Py_LIMITED_API is defined, so many people treat them as part of Limited API already. The same goes for Py_IS_TYPE.

Let's turn them into real function symbols, and keep the static inline variants in the non-Limited API only.


Note that I don't propose exposing Py_SET_TYPE this way. The proper way to change an object's type is setting the __class__ Python attribute, which does proper checks and reference counting.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions