Added a semi-accurate refcount measure to objects.

This commit is contained in:
Jeremy Fincher 2003-08-11 05:06:41 +00:00
parent 0cf850dfc1
commit 1bbcfa9a5e

View File

@ -486,6 +486,7 @@ class FunCommands(callbacks.Privmsg):
dicts = 0
lists = 0
tuples = 0
refcounts = 0
objs = gc.get_objects()
for obj in objs:
if isinstance(obj, tuple):
@ -500,11 +501,12 @@ class FunCommands(callbacks.Privmsg):
classes += 1
elif inspect.ismodule(obj):
modules += 1
refcounts += sys.getrefcount(obj)
response = 'I have %s objects: %s modules, %s classes, %s functions, '\
'%s dictionaries, %s lists, and %s tuples (and a few other'\
' different types).' %\
' different types). I have a total of %s references.' %\
(len(objs), modules, classes, functions,
dicts, lists, tuples)
dicts, lists, tuples, refcounts)
irc.reply(msg, response)
def last(self, irc, msg, args):