Skip to content

Immortal objects and the C API docs #104597

Closed
@JelleZijlstra

Description

@JelleZijlstra

https://docs.python.org/3.12/c-api/none.html#c.Py_None currently says that Py_None "needs to be treated just like any other object with respect to reference counts". That's not really true now that we have PEP-683 immortal objects: there is no need to incref/decref it. There are several similar places, e.g. https://docs.python.org/3.12/c-api/slice.html#ellipsis-object and https://docs.python.org/3.12/c-api/bool.html#c.Py_False.

The docs should be updated to somehow refer to the fact that these objects are immortal. However, extension authors who want to retain support for 3.11 and lower should continue to refcount None etc. correctly, so we shouldn't completely omit discussion of refcounting.

cc @eduardo-elizondo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions