Traversing the object space.

L

Lothar Scholz

Ruby has a nice function that can traverse the complete object space
of your program.

Is there anything like this in python ? It seems to be not in the
standart library but maybe i can find a short script somewhere else.

It is a nice way for to do some memory checks to find out if a part of
your app is generating too much objects.
 
J

Jp Calderone

Ruby has a nice function that can traverse the complete object space
of your program.

Is there anything like this in python ? It seems to be not in the
standart library but maybe i can find a short script somewhere else.

It is a nice way for to do some memory checks to find out if a part of
your app is generating too much objects.


import gc
print gc.get_objects()

Jp
 
M

Mark Hahn

Ruby has a nice function that can traverse the complete object space
import gc
print gc.get_objects()

Does this only report objects that support the garbage collector?
 
M

Michael Hudson

Ruby has a nice function that can traverse the complete object space
of your program.

Is there anything like this in python ?

In a debug build, there's sys.getobjects(). In recent release builds,
there's gc.get_objects() which I think only returns containers, but a
bit of creativity can find all objects from there (note that, unless
you try really hard instances of any classes you define will count as
containers).

Cheers,
mwh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top