Skip to main content

Python Call Graph is a library and command line tool that visualises the flow of your Python application. This is a fork of the original, updated to work with Python 3.5 - 3.11 and from 2.1.4 3.8 - 3.13 See https://lewiscowles1986.github.io/py-call-graph/ for more information.

Project description

Python Call Graph

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

This repo used to be pycallgraph which is still hosted at pypi link.

The uploader makes no representations of their contribution, and merely wanted this to work in python 3.5; with a goal to porting it to 3.11, 3.12 and 3.13

[! NOTE] Please give more ideas for problems or further use-cases for this repo. I am really glad folks like it, but it's mostly the original author work, and I don't yet know what more to add to this.

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.1.4 which was released on 2025-06-06. The latest version has been tested running on Python versions 3.8 - 3.13

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.8 - 3.13.
  • 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 python-call-graph

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.1.4.tar.gz (471.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: python-call-graph-2.1.4.tar.gz
  • Upload date:
  • Size: 471.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for python-call-graph-2.1.4.tar.gz
Algorithm Hash digest
SHA256 e97cbff31e0759d419fac9b42501625b075bdf43b7ff8209223c0034d27abbf1
MD5 35ba2aecfefbd4c910d1cb83e207ed3c
BLAKE2b-256 b4b6de26edf42bf7b6d6c309c623abbc4f8b0b0a4ab7af8b70c75c79d0e5583e

See more details on using hashes here.

Provenance

The following attestation bundles were made for python-call-graph-2.1.4.tar.gz:

Publisher: release.yml on Lewiscowles1986/py-call-graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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