Skip to main content

Python Call Graph is a library and command line tool that visualises the flow of your Python application. See http://pycallgraph.slowchop.com/ for more information.

Project description

Python Call Graph

Welcome! Python Call Graph is a Python module that creates call graph visualizations for Python applications.

CI Status

Screenshots

Click on the images below to see a larger version and the source code that generated them.

Basic Output thumbnail

Regex grouped Output thumbnail

Regex ungrouped Output thumbnail

Project Status

The latest version is 2.0.0 which was released on 2024-03-31, and is a backwards incompatible from the previous release, dropped 2.7 support and is targetting the quite old Python 3.5.

The project lives on GitHub, where you can report issues, contribute to the project by forking the project then creating a pull request, or just browse the source code.

The documentation needs some work stiil. Feel free to contribute :smile:

Features

  • Support for Python 3.5.
  • Static visualizations of the call graph using various tools such as Graphviz and Gephi.
  • Execute pycallgraph from the command line or import it in your code.
  • Customisable colors. You can programatically set the colors based on number of calls, time taken, memory usage, etc.
  • Modules can be visually grouped together.
  • Easily extendable to create your own output formats.

Quick Start

Installation is easy as

pip install pycallgraph

You can either use the command-line interface for a quick visualization of your Python script, or the pycallgraph module for more fine-grained settings.

The following examples specify graphviz as the outputter, so it's required to be installed. They will generate a file called pycallgraph.png.

The command-line method of running pycallgraph is::

pycallgraph graphviz -- ./mypythonscript.py

A simple use of the API is::

from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutput

with PyCallGraph(output=GraphvizOutput()):
    code_to_profile()

Documentation

Feel free to browse the documentation of pycallgraph for the usage guide and API reference.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-call-graph-2.0.0.tar.gz (465.9 kB view details)

Uploaded Source

File details

Details for the file python-call-graph-2.0.0.tar.gz.

File metadata

  • Download URL: python-call-graph-2.0.0.tar.gz
  • Upload date:
  • Size: 465.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for python-call-graph-2.0.0.tar.gz
Algorithm Hash digest
SHA256 efb72c23992f0c5e70b4888759f39e8a1323aba79ef38c19105e9c875253c126
MD5 e273bb094d53ba27e0469f771808bb26
BLAKE2b-256 3fb7ea8ffc3be46e56abdb7c644310d5a111bcb316116b4ccf394f8f9327f4cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page