This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients brandtbucher, pablogsal, rhettinger, serhiy.storchaka, tim.peters, vstinner
Date 2020-12-03.20:27:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607027276.71.0.808160797489.issue42536@roundup.psfhosted.org>
In-reply-to
Content
> I added some comments in the PR regarding the possibility of forcing the tracking on the visiting function to redirect the cost to gc passes instead of when calling next()...

Yep, I agree that this approach is better.

> ...but there is another option: not untracking tuples that have refcount == 1.

I do like the idea of not having to fix this in ~10 different places, but I'm not sure this is enough. The GC visit may happen when the refcount of the result tuple is > 1, but it may drop back to 1 before __next__ called again

z = zip([42, []])
item = next(zip)
gc.collect()  # Refcount of item == 2, untracked by GC.
del item  # Refcount of item == 1, ready to be recycled.
next(zip)  # This should be tracked, but won't be.
History
Date User Action Args
2020-12-03 20:27:56brandtbuchersetrecipients: + brandtbucher, tim.peters, rhettinger, vstinner, serhiy.storchaka, pablogsal
2020-12-03 20:27:56brandtbuchersetmessageid: <1607027276.71.0.808160797489.issue42536@roundup.psfhosted.org>
2020-12-03 20:27:56brandtbucherlinkissue42536 messages
2020-12-03 20:27:56brandtbuchercreate