Object counts

Chuck Esterbrook ChuckEsterbrook at yahoo.com
Sat Feb 23 16:29:29 EST 2002


Hi,

Is there a way to get Python to report the number of instances of all 
classes and types? e.g., a dictionary that would map the names of 
types/classes to their count, which would be incremented on creation 
and decremented on deletion?

If not, how hard would it be to patch Python for this? Seems like all 
creation and destruction would eventually go through a couple places in 
the Python C implementation.

This would be useful for understanding how your program uses memory 
(kind of like the memory version of profile) and also for hunting down 
memory leaks.

-Chuck



More information about the Python-list mailing list