-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-124074: Add _Py_NewImmortalRef() function #124076
Conversation
vstinner
commented
Sep 13, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: [C API] Add _Py_NewImmortalRef() function to the internal C API #124074
cc @encukou |
// Similar to Py_NewRef() but for immortal objects. | ||
// obj must be immortal. | ||
static inline PyObject* _Py_NewImmortalRef(PyObject *obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP 7:
// Similar to Py_NewRef() but for immortal objects. | |
// obj must be immortal. | |
static inline PyObject* _Py_NewImmortalRef(PyObject *obj) | |
// Similar to Py_NewRef() but for immortal objects. | |
// obj must be immortal. | |
static inline PyObject * | |
_Py_NewImmortalRef(PyObject *obj) |
If you ask me: I don't think this is useful without
|
Do you mean a tool which would fail if |
For clarification: would |
It works on any immortal object: https://docs.python.org/dev/glossary.html#term-immortal |
AFAIK, it would only need the existing |
It's more complicated than that since Python/ceval.c now converts immortal objects to "stack ref" objects and it doesn't call DECREF on them on purpose. Maybe it's a lost battle and we should give up on doing |
Yeah, it would need to start doing that DECREF, in debug builds. Otherwise, |
I prefer to abandon this function at this point. I failed to update Py_INCREF(), Py_DECREF() and _Py_NewImmortalRef() to keep a consistent "total ref count" using |