pympler.refbrowser

Tree-like exploration of object referrers.

This module provides a base implementation for tree-like referrers browsing. The two non-interactive classes ConsoleBrowser and FileBrowser output a tree to the console or a file. One graphical user interface for referrers browsing is provided as well. Further types can be subclassed.

All types share a similar initialisation. That is, you provide a root object and may specify further settings such as the initial depth of the tree or an output function. Afterwards you can print the tree which will be arranged based on your previous settings.

The interactive browser is based on a TreeWidget implemented in IDLE. It is available only if you have Tcl/Tk installed. If you try to instantiate the interactive browser without having Tkinter installed, an ImportError will be raised.

Classes

class pympler.refbrowser.RefBrowser(rootobject, maxdepth=3, str_func=<function _repr>, repeat=True, stream=None)

Base class to other RefBrowser implementations.

This base class provides means to extract a tree from a given root object and holds information on already known objects (to avoid repetition if requested).

get_tree()

Get a tree of referrers of the root object.

class pympler.refbrowser.ConsoleBrowser(*args, **kwargs)

RefBrowser that prints to the console (stdout).

print_tree(tree=None)

Print referrers tree to console.

keyword arguments tree – if not None, the passed tree will be printed. Otherwise it is based on the rootobject.

class pympler.refbrowser.FileBrowser(rootobject, maxdepth=3, str_func=<function _repr>, repeat=True, stream=None)

RefBrowser implementation which prints the tree to a file.

print_tree(filename, tree=None)

Print referrers tree to file (in text format).

keyword arguments tree – if not None, the passed tree will be printed.

class pympler.refbrowser.InteractiveBrowser(rootobject, maxdepth=3, str_func=<function gui_default_str_function>, repeat=True)

Interactive referrers browser.

The interactive browser is based on a TreeWidget implemented in IDLE. It is available only if you have Tcl/Tk installed. If you try to instantiate the interactive browser without having Tkinter installed, an ImportError will be raised.

main(standalone=False)

Create interactive browser window.

keyword arguments standalone – Set to true, if the browser is not attached to other windows