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
|
Graph searches
--------------
The other day I was wondering why pickling a particular object errored out
with an error deep in one of the subobjects.
>>> class MyUnpicklableObject(object):
... def __getstate__(self):
... raise NotImplementedError
...
>>> my_object = dict(foo=dict(unrelated='things'),
... bar=[dict(nesting='fun'),
... dict(boobytrap=MyUnpicklableObject())])
>>> import objgraph
>>> objgraph.show_chain(
... objgraph.find_ref_chain(
... my_object,
... lambda x: isinstance(x, MyUnpicklableObject)),
... backrefs=False,
... filename='forward-chain.png')
Graph written to ...dot (4 nodes)
Image generated as forward-chain.png
.. figure:: chain.png
:alt: [chain of references from my_object to a MyUnpicklableObject instance]
|