mgedmin / objgraph

Visually explore Python object graphs
http://mg.pov.lt/objgraph/
MIT License
753 stars 72 forks source link

Blocking given objects from further expansion. #75

Open thisismygitrepo opened 1 year ago

thisismygitrepo commented 1 year ago

Can we please have a direly missing option to block given objects from further expansion? For example, I want to have very deep expansion of my object but I don't want to expose any low level details of foreign objects, e.g. pandas dataframe. Unless I'm very much mistaken, I couldn't see an option for this. Thank you.

mgedmin commented 1 year ago

The filter argument for objgraph.show_refs()/objgraph.show_backrefs() works like this. E.g.

objgraph.show_refs([start], filter=lambda x: not isinstance(x, pandas.DataFrame))

I see that it is rather underdocumented. The docs for objgraph.typestats() also has it, and describes it as

If filter is specified, it should be a function taking one argument and returning a boolean. Objects for which filter(obj) returns False will be ignored.

and I should copy the second sentence and include it in the explanation of filter in the docs for show_refs/backrefs.

thisismygitrepo commented 1 year ago

Thanks for showing this. I'm aware of this one already and it is a bit restricted in its functionality.

J12D commented 4 months ago

+1 this would be helpful — essentially I want to express “render objects of this type, but don’t expand them further”.