[Python-Dev] Lazily GC tracking tuples

Martin v. Loewis martin@v.loewis.de
05 May 2002 09:49:20 +0200

Daniel Dunbar <evilzr@yahoo.com> writes:

> Lazily tracking the tuples seems to be a much simpler
> proposition

This proposal sounds good, but there are a few issues.

> and PyTuple_SET_ITEM and PyTuple_SetItem are modified

This is a problem: PyTuple_SET_ITEM is compiled into the extension
module, so you need to bump the API version (or else old modules
would be used that do not have your change).

> In theory if v is a tuple, _SetItem(o,i,v) should only 
> be called when v has been completely filled, so if v
> is untracked then we know it also cannot be member of a
> cycle, which solves the nested tuple problem.

I think it is safe to make this assumption. The worst case is that you
get cyclic garbage that won't be collected. Given that it is a bug to
refer to an "incomplete" tuple, I think this consequence of this bug
is acceptable.

> A 2.23 patch for the changes outlined above are at:
> http://www.geocities.com/evilzr/lazytuplegc/
> (I wasn't sure if such things are appropriate for
> the SF-patch manager - yes/no?)

If you think this patch is reasonably complete, and you wish that it
is included in Python, then yes, put it onto SF.