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] |
|
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. |
|
I will merge backport patch after my dinner :) |
Found while working on #95001