Created
January 7, 2013 18:58
-
-
Save blazetopher/4477463 to your computer and use it in GitHub Desktop.
Utilities for working with objgraph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
@package | |
@file objgraph_utils | |
@author Christopher Mueller | |
@brief | |
""" | |
import objgraph | |
max_depth = 5 | |
too_many = 100 | |
def show_refs(obj=None, obj_id=None): | |
if obj is None and obj_id is not None: | |
obj = get_obj_by_id(obj_id) | |
objgraph.show_refs(obj, max_depth=max_depth, too_many=too_many, extra_info=lambda x: id(x), filter=lambda x: not isinstance(x, type), refcounts=True) | |
def show_backrefs(obj=None, obj_id=None): | |
if obj is None and obj_id is not None: | |
obj = get_obj_by_id(obj_id) | |
objgraph.show_backrefs(obj, max_depth=max_depth, too_many=too_many, extra_info=lambda x: id(x), filter=lambda x: not isinstance(x, type), refcounts=True) | |
def get_obj_by_id(obj_id): | |
return objgraph.at(obj_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment