All Projects → osteele → callgraph

osteele / callgraph

Licence: MIT License
Magic to display dynamic call graphs of Python function calls

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to callgraph

Kali-Linux-Tools-Interface
Graphical Web interface developed to facilitate the use of security information tools.
Stars: ✭ 169 (+218.87%)
Mutual labels:  education
rest-apis-flask-python
A small repository of projects built in my course, REST APIs with Flask and Python.
Stars: ✭ 861 (+1524.53%)
Mutual labels:  education
5MinuteFinance
Interactive Presentations for Financial Education using R/Shiny. See full list of presentations (with links) below.
Stars: ✭ 69 (+30.19%)
Mutual labels:  education
mooc-java-programming-i
University of Helsinki’s free massive open online course (MOOC) completed exercises. 2020 solutions
Stars: ✭ 16 (-69.81%)
Mutual labels:  education
championscurriculum
A training curriculum for teaching information security "champions" within small organisations and helping them conduct a basic assessment. (Work in progress)
Stars: ✭ 18 (-66.04%)
Mutual labels:  education
MLSummerSchool
Материалы факультатива по машинному обучению и искусственному интеллекту
Stars: ✭ 27 (-49.06%)
Mutual labels:  education
drmips
I don't maintain this project anymore. Feel free to fork it! - Educational MIPS simulator
Stars: ✭ 41 (-22.64%)
Mutual labels:  education
kui
A hybrid command-line/UI development experience for cloud-native development
Stars: ✭ 2,137 (+3932.08%)
Mutual labels:  visualizations
antares
Digital circuit learning platform
Stars: ✭ 15 (-71.7%)
Mutual labels:  education
resources
Resource Library of IEEE-VIT
Stars: ✭ 33 (-37.74%)
Mutual labels:  education
tiny-framework
A light wight easy to use RESTful apis framework for education & demo purposes. stripped down framework to the fundamental components that that every one would essentially need to (learn / make a demo application).
Stars: ✭ 13 (-75.47%)
Mutual labels:  education
ICM-2018
Syllabus for ITP Foundation Course Introduction to Computational Media, Fall 2018
Stars: ✭ 57 (+7.55%)
Mutual labels:  education
RuralEducation
An app that helps rural students in their education.I used Firebase Realtime database,authentication,Networking requests,User Chats,Google Places Api,Paytm Payment Gateway Integration,Google places Autocomplete Api,Firebase Chat
Stars: ✭ 22 (-58.49%)
Mutual labels:  education
FlipED
A LMS built specifically for Thailand's Education 4.0 system.
Stars: ✭ 24 (-54.72%)
Mutual labels:  education
Java
All Examples for learning Java programming and algorithms
Stars: ✭ 14 (-73.58%)
Mutual labels:  education
quiz-extensions
A self-service LTI for faculty to easily extend time for multiple users for all quizzes at once.
Stars: ✭ 15 (-71.7%)
Mutual labels:  education
lehrfempp
Simplistic Finite Element Framework for research and eduction
Stars: ✭ 14 (-73.58%)
Mutual labels:  education
Prelude
A web app for practicing musical sight reading skills
Stars: ✭ 24 (-54.72%)
Mutual labels:  education
data-mining-course
An undergraduate course on data mining.
Stars: ✭ 24 (-54.72%)
Mutual labels:  education
udacity-iOS-nanodegrees
List of iOS Udacity Nanodegree programs with links to the free courses in their curricula
Stars: ✭ 52 (-1.89%)
Mutual labels:  education

Callgraph Magic

Latest PyPI Version Documentation Status License Supported Python Versions

Callgraph is a Python package that defines a decorator, and Jupyter magic, to draw dynamic call graphs of Python function calls.

It’s intended for classroom use, but may also be useful for self-guided exploration.

The package defines a Jupyter IPython magic, %callgraph, that displays a call graph within a Jupyter cell:

from functools import lru_cache

@lru_cache()
def lev(a, b):
    if "" in (a, b):
        return len(a) + len(b)

    candidates = []
    if a[0] == b[0]:
        candidates.append(lev(a[1:], b[1:]))
    else:
        candidates.append(lev(a[1:], b[1:]) + 1)
    candidates.append(lev(a, b[1:]) + 1)
    candidates.append(lev(a[1:], b) + 1)
    return min(candidates)

%callgraph -w10 lev("big", "dog"); lev("dig", "dog")

image0

It also provides a Python decorator, callgraph.decorator, that instruments a function to collect call graph information and render the result.

Jupyter / IPython Usage

$ pip install callgraph

In a Jupyter IPython notebook:

%load_ext callgraph

def nchoosek(n, k):
    if k == 0:
        return 1
    if n == k:
        return 1
    return nchoosek(n - 1, k - 1) + nchoosek(n - 1, k)

%callgraph nchoosek(4, 2)

As an alternative to including %load_ext callgraph in each notebook that uses %callgraph, you can add the extension to the Notebook configuration file in your IPython profile.

Your configuration file is probably called ~/.ipython/profile_default/ipython_config.py. (You can run ipython profile locate to find it.) Edit this file to include the following line:

c.InteractiveShellApp.extensions = ["callgraph.extension"]

(If your configuration file already includes an uncommented statement c.InteractiveShellApp.extensions = […], edit the list of extensions in that line to include "callgraph.extension".

See extension example notebook for additional examples.

Decorator Usage

$ pip install callgraph
from functools import lru_cache
import callgraph.decorator as callgraph

@callgraph()
@lru_cache()
def nchoosek(n, k):
    if k == 0:
        return 1
    if n == k:
        return 1
    return nchoosek(n - 1, k - 1) + nchoosek(n - 1, k)

nchoosek(5, 2)

nchoosek.__callgraph__.view()

See the API documentation for additional documentation.

See the decorator example notebook for additional instructions and examples.

Development

Install dev tools, and set up a Jupyter kernel for the current python enviromnent:

$ pip install -r requirements-dev.txt
$ python -m ipykernel install --user

Install locally:

flit install --symlink

Acknowledgements

Callgraph uses the Python graphviz package. Python graphviz uses the Graphviz package.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].