Skip to main content

A Sampling Profiler for Python

Project description

py-spy is a fast sampling profiler for Python programs. py-spy lets you visualize what your Python program is doing without restarting the program or modifying the code in any way. py-spy is low overhead and won’t pause or slow your Python program down - meaning that it is safe to use in production.

To install:

pip install py-spy

py-spy supports Python versions 2.3+ and 3.3+ on Linux, OSX and Windows.


py-spy works from the command line, and takes either the PID of the program you want to sample from, or the command line of the python program you want to run:

py-spy --pid 12345
# OR
py-spy -- python

The default visualization is a top-like live view of your python program:

console viewer demo

console viewer demo

There is also support for generating flame graphs from the running process:

py-spy --flame profile.svg --pid 12345
# OR
py-spy --flame profile.svg -- python

Which will generate a SVG file looking like:

flame graph

flame graph


py-spy is heavily inspired by Julia Evans excellent work on rbspy. In particular the code to generate the flamegraphs is taken directly from rbspy, and this project use several crates (read-process-memory and proc-maps) that were spun off from rbspy.

Project details

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

py_spy-0.1.0-py2.py3-none-manylinux1_x86_64.whl (5.7 MB view hashes)

Uploaded Python 2 Python 3

py_spy-0.1.0-py2.py3-none-macosx_10_7_x86_64.whl (3.0 MB view hashes)

Uploaded Python 2 Python 3 macOS 10.7+ x86-64

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