Brian Quinlan
Martin wrote:
You don't have to add it to every method. You can perform the check in tp_getattro before performing the method lookup.
That would be dangerous! See my original "more evil" example.
Yeah, doesn't work for that case.
Alternatively, you can change the ob_type of the object to simply drop
the methods that are not available anymore.
I like this strategy! But I still think that this is more painful/less elegant than using proxies.
I don't see how that works either. If you have two objects of the same type, they may die at different times. If the type drops its methods all the objects become disabled. Furthermore, I think it still doesn't help with "more evil", since nobody's touching the type at that point - the method has already been looked up and kept alive by binding it to the underlying object. -- David Abrahams dave@boost-consulting.com * http://www.boost-consulting.com Building C/C++ Extensions for Python: Dec 9-11, Austin, TX http://www.enthought.com/training/building_extensions.html