-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
gh-143300: implement PyUnstable_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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kumaraditya303
wants to merge
9
commits into
python:main
Choose a base branch
from
kumaraditya303:immortal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−0
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b874f0b
implement PyUnstable_SetImmortal
kumaraditya303 cb6cc99
fix compilation under ft
kumaraditya303 c897a08
minor fixes
kumaraditya303 f00e23f
Apply suggestions from code review
kumaraditya303 f42377a
address review
kumaraditya303 ed5389c
Merge branch 'main' into immortal
kumaraditya303 9987a92
add more tests
kumaraditya303 9a4003c
fix test on ft
kumaraditya303 8fe0fb5
fix lint
kumaraditya303 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -801,3 +801,19 @@ 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 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. | ||
|
|
||
| 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. | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Up to you, but it's likely worth mentioning that this is useful for avoiding reference count contention. |
||
| .. versionadded:: next | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Oh, we also need to note that
opwill be GC-untracked if it's tracked.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.
Isn't it the same as never garbage collected?
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.
I don't think that's immediately clear. Something can be "never garbage collected" while still being GC-tracked without being immortal (such as with a reference leak). It'd be nice for users to know that they don't need to call
PyObject_GC_UnTrackthemselves.