[Python-Dev] Class destructor
Phillip J. Eby
pje at telecommunity.com
Wed Feb 28 18:51:16 CET 2007
At 05:24 PM 2/28/2007 +0000, Nick Maclaren wrote:
>I suppose that I could add a C object as an attribute that points to
>a block of memory that contains copies of all my workspace pointers,
>and use the object deallocator to clean up. If all else fails, I
>will try that, but it seems a hell of a long way round for what I
>would have thought was a basic requirement.
Well, you could use a custom metaclass with a tp_dealloc or whatever. But
I just mainly meant that a PyCObject is almost as good as a weakref for
certain purposes -- i.e. it's got a pointer and a callback.
You could of course also use weak references, but that's a bit more awkward
as well.
More information about the Python-Dev
mailing list