bpo-38379: Don't block collection of unreachable objects when some objects resurrect by pablogsal · Pull Request #16687 · python/cpython (original) (raw)
I'm not looking to do less work than check_garbage
, just looking to do it once instead of twice. More, I think it's a Bad Idea to follow this module's lead of being as "clever" as possible with no regard for how brittle that makes the code. Do the simplest & most straightforward thing instead?
Looking at older versions of this code is good for the soul 😃 Neil's original was a joy to work with, subtle algorithms but coded in completely straightforward ways. I dare say I improved some on that, by introducing a concrete notion of "state", with well defined transitions that were trivial to implement and query. Pointers were always pointers, ints were always ints ...
But the gc header struct had 3 members then (next, prev, and refcount copy). All the pain was introduced to get rid of the header's refcount member, and almost nothing was straightforward anymore. It's not a trade-off I would have made, but it's certainly defensible.
In any case, the ubiquitous bit fiddling now also slowed the code. I don't at all mind making it a bit slower still to preserve some sanity 😜