Message382455
> I added some comments in the PR regarding the possibility of forcing the tracking on the visiting function
Thinking about this more, I'm a bit hesitant to put the re-tracking code in the traverse function (mostly stemming from my lack of knowledge about our GC algorithm). I have no idea how problematic tracking and untracking objects *during* collections can be. Consider the following reference chain:
-> z -> r -> o -> r
Here, z is a zip iterator, r is its result tuple, and o is some object. Let's say r was untracked in the previous collection (I believe untrack_tuples happens *after* all of the traverse functions are called).
I'm worried that the GC may not be able to detect the cycle if it visits o, then z (which *then* starts tracking r), then r.
Or, if this group is determined to be unreachable, untrack_tuples untracks r *before* the cycle is cleaned up. That seems like it could be a problem.
Or, if z's refcount drops to zero and it's cleaned up, its traverse function may *never* be called, which leaves the untracked r -> o -> r cycle.
I guess I'm just not sure how resilient the GC is to these sorts of things. Re-tracking the result tuple in __next__ sidesteps all of these potential issues, with no significant performance impact. So I think I might slightly prefer that. |
|
Date |
User |
Action |
Args |
2020-12-03 22:13:17 | brandtbucher | set | recipients:
+ brandtbucher, tim.peters, rhettinger, vstinner, serhiy.storchaka, pablogsal |
2020-12-03 22:13:17 | brandtbucher | set | messageid: <1607033597.17.0.388795887836.issue42536@roundup.psfhosted.org> |
2020-12-03 22:13:17 | brandtbucher | link | issue42536 messages |
2020-12-03 22:13:16 | brandtbucher | create | |
|