Python 2.3.4 When heap allocated type objects are created, they will be added to their base class's tp_subclasses list as a weak reference. If, for example, your base type is PyBaseObject_Type, then the tp_subclasses list for the base object type will grow for each new object. Unfortunately remove_subclass is never called. If your newly create type objects are deleted, then you will end up with a bunch of weak reference objects in the tp_subclasses list that do not reference anything. Perhaps remove_subclass should be called inside type_dealloc? Or, better yet, tp_subclasses should be a Weak Set. I'm not certain what's the best solution.
Logged In: YES user_id=6656 It's not quite as bad as you might think, because add_subclass will stomp on a dead reference if it finds one. So the length of tp_subclasses is bounded by the number of bases that exist at any one time, which doesn't seem too bad to me. Still, it would seem cleaner to do the removal at type_dealloc time...