Brandt Bucher <brandtbuc...@gmail.com> added the comment:
> 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42536> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com