[Pythonmac-SIG] RefCount ?

Peter Sommerfeld peter.sommerfeld@gmx.de
Sat, 1 May 1999 13:23:49 +0200


Just van Rossun wrote:
>At 4:22 AM +0200 5/1/99, Peter Sommerfeld wrote:
>>I have some objects which contain elements with direkt references
>>back to the object. It would be possible to avoid any danger if I could
>>decrement the refcount of the object at assignment. There is sys.getrefcount
>>but is there somewhere it's counterpart, set refount ? This seems to be
>>possible on C-level only. Or is there somewhere a hidden backdoor or dirty
>>hack to accomplish this ?
>
>You *really* don't want to do this.
>
>Either provide a close() method that breaks the circular refs (which you'll
>have to call explicitly) or reconsider your design: right now I'm working
>on a fairly large library in which I prevent the problem by passing the
>parent object as an extra argument to certain method calls. This works real
>nice for me.

Yes, I'm aware of this possibilities. But these add some unneccesary
complexity.
It would really be very nice to make __del__ "closing" the object automaticly.
To decrement the refcount would *really* be the least dangerous, fastest and
most reliable solution.

>Disclaimer: I'm not an OO expert, so it may be all rubbish what I'm saying.
>
>Just

Me too. But I will become one if I continue to redesign the design ;)

-- Peter  (still hoping to avoid C-level while prototyping)