Skip to main content

A Sampling Profiler for Python

Project description

Build Status Windows Build status

Py-Spy is a sampling profiler for Python programs. It lets you visualize what your Python program is spending time on without restarting the program or modifiying the code in any way. Py-Spy is extremely low overhead: it is written in Rust for speed and doesn’t pause or slow down the profiled Python program. This means Py-Spy is safe to use in production.

Py-Spy works on Linux, OSX and Windows, and supports profiling all recent versions of the CPython interpreter (versions 2.3-2.7 and 3.3-3.7).

Installation

Prebuilt binary wheels can be installed from PyPI with:

pip install py-spy

Usage

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 myprogram.py

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 myprogram.py

Which will generate a SVG file looking like:

flame graph

flame graph

Credits

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.2-py2.py3-none-manylinux1_x86_64.whl (5.9 MB view hashes)

Uploaded Python 2 Python 3

py_spy-0.1.2-py2.py3-none-macosx_10_7_x86_64.whl (3.1 MB view hashes)

Uploaded Python 2 Python 3 macOS 10.7+ x86-64

py_spy-0.1.2-cp36-cp36m-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

py_spy-0.1.2-cp36-cp36m-win32.whl (1.1 MB view hashes)

Uploaded CPython 3.6m Windows x86

py_spy-0.1.2-cp35-cp35m-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.5m Windows x86-64

py_spy-0.1.2-cp35-cp35m-win32.whl (1.1 MB view hashes)

Uploaded CPython 3.5m Windows x86

py_spy-0.1.2-cp27-cp27m-win32.whl (1.1 MB view hashes)

Uploaded CPython 2.7m Windows x86

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