This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tp_subclasses grow without bounds
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ehuss, georg.brandl, mwh
Priority: normal Keywords:

Created on 2004-06-26 00:54 by ehuss, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg60524 - (view) Author: Eric Huss (ehuss) Date: 2004-06-26 00:54
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.

msg60525 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-06-29 18:55
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...
msg60526 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-08-07 21:19
Logged In: YES 
user_id=6656

Do you still think this is a problem?
msg70087 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-20 12:01
After all this time, it should be safe to close this.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40459
2008-07-20 12:01:33georg.brandlsetstatus: open -> closed
resolution: wont fix
messages: + msg70087
nosy: + georg.brandl
2004-06-26 00:54:45ehusscreate