mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Added a semi-accurate refcount measure to objects.
This commit is contained in:
parent
0cf850dfc1
commit
1bbcfa9a5e
@ -486,6 +486,7 @@ class FunCommands(callbacks.Privmsg):
|
|||||||
dicts = 0
|
dicts = 0
|
||||||
lists = 0
|
lists = 0
|
||||||
tuples = 0
|
tuples = 0
|
||||||
|
refcounts = 0
|
||||||
objs = gc.get_objects()
|
objs = gc.get_objects()
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
if isinstance(obj, tuple):
|
if isinstance(obj, tuple):
|
||||||
@ -500,11 +501,12 @@ class FunCommands(callbacks.Privmsg):
|
|||||||
classes += 1
|
classes += 1
|
||||||
elif inspect.ismodule(obj):
|
elif inspect.ismodule(obj):
|
||||||
modules += 1
|
modules += 1
|
||||||
|
refcounts += sys.getrefcount(obj)
|
||||||
response = 'I have %s objects: %s modules, %s classes, %s functions, '\
|
response = 'I have %s objects: %s modules, %s classes, %s functions, '\
|
||||||
'%s dictionaries, %s lists, and %s tuples (and a few other'\
|
'%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,
|
(len(objs), modules, classes, functions,
|
||||||
dicts, lists, tuples)
|
dicts, lists, tuples, refcounts)
|
||||||
irc.reply(msg, response)
|
irc.reply(msg, response)
|
||||||
|
|
||||||
def last(self, irc, msg, args):
|
def last(self, irc, msg, args):
|
||||||
|
Loading…
Reference in New Issue
Block a user