[XML-SIG] Re: FREE DOM
Tue, 8 Sep 1998 16:53:34 +0100
> One solution is to require calling a .destroy() (or
>similarly-named) method when you're done with a node. The method
>would then do something like:
> def destroy(self):
> del self.parent
> for i in self.children:
> del self.children
>This is simple to implement, but it means that you have to remember to
>call .destroy(). Does anyone see a representation that would avoid
>the necessity of doing this? I was thinking of just having .children
>in each node, and then there would be a global dictionary that mapped
>nodes to their parent objects. Because it's global, it wouldn't
>participate in any cycles, but cleaning it up is also a pain.
Yup. *When* should you do the clean-up in that case? Since all
nodes will have an extra reference (from the global dictionary),
they'll never go away unless you explicitly call a cleanup function...
(alright, you can have a "purge" function that kills nodes with
reference count=1, and use a background thread to call that
function now and then...)
I definitely prefer the "destroy" pattern (or rather, I prefer to
use visitors for this, but that's another story).
> Anyone have a suggestion? (Other than continually visiting
>Guido and whining for non-refcounting GC?)
Well, I see no reason why you cannot keep on doing that as well ;-)
PS. Does anyone have pointers to SAXDOM and/or FreeDOM?