Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.3k
gh-143300: implementPyUnstable_SetImmortal#144543
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
b874f0bcb6cc99c897a08f00e23ff42377aed5389c9987a929a4003c8fe0fb5a146befe1ef13dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -801,3 +801,20 @@ Object Protocol | ||
| cannot fail. | ||
| .. versionadded:: 3.14 | ||
| .. c:function:: int PyUnstable_SetImmortal(PyObject *op) | ||
| Marks the object *op* :term:`immortal`. The argument should be uniquely referenced by | ||
| the calling thread. This is intended to be used for reducing reference counting contention | ||
| in the :term:`free-threaded build` for objects which are shared across threads. | ||
| This is a one-way process: objects can only be made immortal; they cannot be | ||
| made mortal once again. Immortal objects do not participate in reference counting | ||
| and will never be garbage collected. If the object is GC-tracked, it is untracked. | ||
| This function is intended to be used soon after *op* is created, by the code that | ||
| creates it, such as in the object's :c:member:`~PyTypeObject.tp_new` slot. | ||
| Returns 1 if the object was made immortal and returns 0 if it was not. | ||
| This function cannot fail. | ||
kumaraditya303 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| .. versionadded:: next | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add :c:func:`PyUnstable_SetImmortal` C-API function to mark objects as :term:`immortal`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2839,6 +2839,17 @@ PyUnstable_EnableTryIncRef(PyObject *op) | ||
| #endif | ||
| } | ||
| int | ||
| PyUnstable_SetImmortal(PyObject *op) | ||
| { | ||
kumaraditya303 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| assert(op != NULL); | ||
| if (!_PyObject_IsUniquelyReferenced(op) || PyUnicode_Check(op)) { | ||
| return 0; | ||
| } | ||
| _Py_SetImmortal(op); | ||
kumaraditya303 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| return 1; | ||
| } | ||
| void | ||
| _Py_ResurrectReference(PyObject *op) | ||
| { | ||
Uh oh!
There was an error while loading.Please reload this page.