Re: Reference cycles

2017-09-24 Thread Peter Otten
Steve D'Aprano wrote: > Is there a way to log when the garbage collector finds and collects a > reference cycle? > > I don't care about objects claimed by the reference counter, I only care > about cycles. I don't know, and I don't think so. Would a structure like a --- b --- c | | | d

Reference cycles

2017-09-24 Thread Steve D'Aprano
Is there a way to log when the garbage collector finds and collects a reference cycle? I don't care about objects claimed by the reference counter, I only care about cycles. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https:/

Re: Reference Cycles with instance method

2011-03-09 Thread Duncan Booth
Amit Dev wrote: > The object is not garbage collected, since there appears to be a cycle > (between method m2 and A). I would expect this to behave the same as > having another method "def m2(self): self.m1()", but unfortunately its > not. > In above case m2 seems to be in a.__dict__ which is cau

Re: Reference Cycles with instance method

2011-03-09 Thread Peter Otten
Amit Dev wrote: > Simple question. If I have the following code: > > class A: > def __init__(self, s): > self.s = s > self.m2 = m1 > > def m1(self): > pass > > if __name__ == '__main__': > a = A("ads") > a.m1() > a = None > > The object is not garbag

Reference Cycles with instance method

2011-03-08 Thread Amit Dev
Simple question. If I have the following code: class A: def __init__(self, s): self.s = s self.m2 = m1 def m1(self): pass if __name__ == '__main__': a = A("ads") a.m1() a = None The object is not garbage collected, since there appears to be a cycle (b

Re: garbage collection / reference cycles (cont.)

2009-03-29 Thread Aaron Brady
On Mar 25, 12:12 am, Aaron Brady wrote: > On Mar 25, 12:11 am, Aaron Brady wrote: > > Hello, > > > I am posting the code I mentioned on Saturday that collects garbage > > and cyclic garbage in a flattened two-step process.  The code takes > > 122 lines incl. comments, with 100 in tests.  It shoul

Re: garbage collection / reference cycles (cont.)

2009-03-29 Thread Aaron Brady
On Mar 25, 12:11 am, Aaron Brady wrote: > Hello, > > I am posting the code I mentioned on Saturday that collects garbage > and cyclic garbage in a flattened two-step process.  The code takes > 122 lines incl. comments, with 100 in tests.  It should be in a reply > to this. > > My aim is a buffer-l

Re: garbage collection / reference cycles (cont.)

2009-03-24 Thread Aaron Brady
On Mar 25, 12:11 am, Aaron Brady wrote: > Hello, > > I am posting the code I mentioned on Saturday that collects garbage > and cyclic garbage in a flattened two-step process.  The code takes > 122 lines incl. comments, with 100 in tests.  It should be in a reply > to this. > > My aim is a buffer-l

garbage collection / reference cycles (cont.)

2009-03-24 Thread Aaron Brady
Hello, I am posting the code I mentioned on Saturday that collects garbage and cyclic garbage in a flattened two-step process. The code takes 122 lines incl. comments, with 100 in tests. It should be in a reply to this. My aim is a buffer-like object which can contain reference-counted objects.