bpo-33597: Reduce PyGC_Head size by methane · Pull Request #7043 · python/cpython (original) (raw)

Since gc->gc.gc_next->gc.gc_prev is not real prev pointer, we can't call _PyTuple_MaybeUntrack(op) here.
I moved it to split function. But it means this pull request adds one more link traversal.

By the way, current code is not idiomatic. While most tuples can be untracked, there are still many tuples
which arn't be untracked. For example, __mro__ or __bases__.
In final generation, we check all tuples contents. In applications which triggers final generation GC frequently,
and there are many tuples, it can be significant overhead.

Anyway, I need to find "tracked tuple heavy" application to benchmark before optimize here.