[LLVMdev] Python bindings available.
Gordon Henriksen
gordonhenriksen at mac.com
Tue May 13 10:25:59 PDT 2008
On May 13, 2008, at 07:31, Mahadevan R wrote:
> Um. Unfortunately in this case, Python will not collect an instance
> of Pet which owned by an Owner, because both objects in the
> reference cycle have finalizers (__del__). Python will just add both
> objects to a garbage list (and will not call any of the finalizers).
Actually, there's no reference cycle, which is what I presume is the
problem you're referring to:
class Owner(pet):
...
def __init__(self, ptr, kid):
self.ptr = ptr
pet.owner = self
Note there is no Owner.pet field. So it should be clear to Python that
Pet must be collected before Owner, which is precisely what we're
trying to tell the GC ('if owner is collected before pet, then pet
becomes a dangling pointer, so don't do that').
— Gordon
More information about the llvm-dev
mailing list