Mapping the object space

By Filip Salo; published on March 09, 2007.

I've talked a little about names and objects in my lectures, and started thinking about how to show what objects are created during execution of a program.

The gc module has a function called get_objects() which returns "a list of objects tracked by the [garbage] collector", which is an excellent start.

This recipe (cached, in case ASPN is still broken) in the cookbook shows a way to ignore a lot of the internals and thus clear the view a bit. (It needed some tweaking to run on my 2.4.3, though.)

Wouldn't it be quite possible to use these tools to draw a visual diagram (graphviz, anyone?) of the relevant names, objects, and references? I wonder...

Update: Well, yes. Not precisely, mind you, but roughly. (Requires 4Suite-XML, which can be easy_installed.)