-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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-94851: fix immortal objects refcounting in compiler #95040
Conversation
@kumaraditya303 Thanks Kumar I was also curious about this code also when you submitted the related patch before.
|
it depends on its usage, if you are owning the object or returning it from a function then incref is required else it is not required. |
If you follow the macro, it is capturing a reference to the new object so incref is required. See comment : |
a = 1
print(f'{a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d}')
|
Nice repro, thanks! |
And I checked that your patch fix this issue. ./python.exe -X showrefcount tt.py
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[0 refs, 0 blocks] |
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.
LGTM.
Please submit the reproducible code if possible it can reduce the reviewer's time and help understanding context :)
I know your patch is correct but reproducible code makes sure what your patch fixes exactly.
Thanks @kumaraditya303 for the PR, and @corona10 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
GH-95049 is a backport of this pull request to the 3.11 branch. |
…h-95040) (cherry picked from commit 7476154) Co-authored-by: Kumar Aditya <[email protected]>
I will merge backport patch after my dinner :) |
(cherry picked from commit 7476154) Co-authored-by: Kumar Aditya <[email protected]>
Found while working on #95001