Skip to content

Promote PyUnstable_Object_GC_NewWithExtraData() to the stable API #148498

@wjakob

Description

@wjakob

Feature or enhancement

Proposal:

Allocating variable sized Python objects via the C API is a genuinely useful operation. It is e.g. needed to

  • implement custom data structures (tuples, lists)
  • implement binding libraries (like nanobind) that co-locate binding data structures with Python objects

So far, the standard way to create them was via PyVarObject, and this was supported even in stable ABI builds. Unfortunately, this data structure becomes inaccessible with the upcoming free-threaded flavor of the stable ABI.

I would like to propose that the function PyUnstable_Object_GC_NewWithExtraData() be promoted to the stable API to provide an escape hatch for extensions that require variable sized objects in abi3t. This will enable extensions to implement variable sized objects without depending on the specifics of PyVarObject.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

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