https://github.com/apaz-cli/graphviewer
For viewing huge object graphs, and finding reference cycles.
https://github.com/apaz-cli/graphviewer
Last synced: about 2 months ago
JSON representation
For viewing huge object graphs, and finding reference cycles.
- Host: GitHub
- URL: https://github.com/apaz-cli/graphviewer
- Owner: apaz-cli
- License: mit
- Created: 2024-08-05T07:07:21.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-08T20:50:52.000Z (over 1 year ago)
- Last Synced: 2024-09-09T21:56:24.265Z (over 1 year ago)
- Language: C
- Size: 1.67 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphViewer
For viewing huge object graphs, and finding reference cycles.
## Installation
```bash
# Pending acceptance to PyPI
pip install objgraph_viewer
```
## Usage
```python
# Let's create some objects to visualize.
class Needle:
def __str__(self):
return "Needle Object"
needle = Needle()
del Needle
# Create a weak reference to the needle
needle_ref = ReferenceType(needle)
# Create a container that holds the needle
haystack = [{"a": tuple}, tuple, [needle], (lambda x: x), 123, "hello"]
# Remove the original reference to needle.
# Now "haystack" is the only object that holds a reference to the Needle object.
del needle
```
```python
# Now, let's use the module to visualize the objects.
import graph_viewer
# Visualize the object graph using a GUI
graph_viewer.collect_and_view(needle_ref)
# Or export to JSON file to view it elsewhere.
graph_viewer.collect_to_json(needle_ref, output_file="graph.json")
graph_viewer.view_json("graph.json")
```