LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

py-spy

Low-overhead sampling profiler for Python

TLDR

Profile running process
$ py-spy top --pid [pid]
copy
Record to file
$ py-spy record -o [profile.svg] --pid [pid]
copy
Dump stacks
$ py-spy dump --pid [pid]
copy
Profile command
$ py-spy record -o [output.svg] -- python [script.py]
copy

SYNOPSIS

py-spy command [options]

DESCRIPTION

py-spy is a sampling profiler for Python programs that works by reading the process memory of a running Python interpreter without requiring any code modifications or restarts. This approach introduces minimal overhead, making it suitable for profiling production workloads.The top subcommand provides a live view of where Python is spending time, similar to the Unix top utility. The record subcommand generates flame graphs in SVG, speedscope, or raw format for detailed analysis, and dump captures stack traces from all threads at a single point in time. Written in Rust, py-spy supports CPython interpreters and can attach to already-running processes by PID.

PARAMETERS

top

Live top-like view.
record
Record to file.
dump
Dump stack traces.
--pid PID
Target process ID.
-o FILE
Output file.
--rate N
Sample rate.

INSTALL

brew install py-spy
copy
nix profile install nixpkgs#py-spy
copy

CAVEATS

Requires root for other users' processes. No code modification needed.

HISTORY

py-spy was created for low-overhead Python profiling.

SEE ALSO

perf(1), python(1), cProfile(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid