Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C API] Add _Py_NewImmortalRef() function to the internal C API #124074

Closed
vstinner opened this issue Sep 13, 2024 · 1 comment
Closed

[C API] Add _Py_NewImmortalRef() function to the internal C API #124074

vstinner opened this issue Sep 13, 2024 · 1 comment
Labels
topic-C-API type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

vstinner commented Sep 13, 2024

I propose adding the following static inline function to the internal C API:

static inline PyObject* _Py_NewImmortalRef(PyObject *obj)
{
    assert(_Py_IsImmortalLoose(obj));
    return obj;
}

It's a way to annotate the code to express that a strong reference is expected, but we also know that the object is immortal and so calling Py_INCREF() is not needed.

See also #103906 and #123972.

Linked PRs

@vstinner
Copy link
Member Author

I abandon this approach: #124076 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants