File: extra-info.txt

package info (click to toggle)
objgraph 3.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,224 kB
  • sloc: python: 1,188; makefile: 108; sh: 8
file content (30 lines) | stat: -rw-r--r-- 799 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Extra information
-----------------

.. currentmodule:: objgraph

You can add extra information to object graphs, if you desire.  For example,
let's add object IDs:

    >>> x = []
    >>> y = [x, [x], dict(x=x)]
    >>> import objgraph
    >>> objgraph.show_refs([y], extra_info=lambda x: hex(id(x)),
    ...                    filename='extra-info.png')
    Graph written to ....dot (... nodes)
    Image generated as extra-info.png

.. figure:: extra-info.png

This way you can then look them up later with :func:`at`, if you desire to
get a closer look at a particular object:

    >>> objgraph.at(id(x)) is x
    True

Warning: this doesn't work with strings or ints or other simple types
that aren't tracked by the cyclic garbage collector:

    >>> a = 'a string'
    >>> objgraph.at(id(a))