~stefanor/objgraph/filename-514422

« back to all changes in this revision

Viewing changes to README.txt

  • Committer: Marius Gedminas
  • Date: 2009-03-24 23:08:10 UTC
  • Revision ID: marius@gedmin.as-20090324230810-gdrmu6hs503wfrod
Create a repository for objgraph.py.  Add a README.txt and a setup.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Python Object Graphs
 
2
====================
 
3
 
 
4
``objgraph`` is a module that lets you visually explore Python object graphs.
 
5
I've used it in the past to go hunt for memory leaks in Python programs as
 
6
described by this series of blog posts:
 
7
 
 
8
* http://mg.pov.lt/blog/hunting-python-memleaks.html
 
9
* http://mg.pov.lt/blog/python-object-graphs.html
 
10
* http://mg.pov.lt/blog/object-graphs-with-graphviz.html
 
11
 
 
12
You'll need `graphviz <http://www.graphviz.org/>`_ if you want to draw
 
13
pretty graphs.
 
14
 
 
15
.. This is a reStructuredText file.  I recommend http://mg.pov.lt/restview
 
16
   for viewing it.
 
17
 
 
18
 
 
19
Examples
 
20
--------
 
21
 
 
22
Try this in a Python shell:
 
23
 
 
24
    >>> x = []
 
25
    >>> y = [x, [x], dict(x=x)]
 
26
    >>> import objgraph
 
27
    >>> objgraph.show_refs([y])
 
28
 
 
29
You should see a graph like this:
 
30
 
 
31
.. image:: sample-graph.png
 
32
    :alt: [graph of objects reachable from y]
 
33
 
 
34
Now try
 
35
 
 
36
    >>> objgraph.show_backrefs([x])
 
37
 
 
38
and you'll see
 
39
 
 
40
.. image:: sample-backref-graph.png
 
41
    :alt: [graph of objects from which y is reachable]
 
42