# py-spy

> Sampling profiler for Python programs

Source: https://talira.ai/catalog/py-spy-mjsrrpca
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Command-line tool
- Categories: [developer tools / performance / profiling](https://talira.ai/categories/developer-tools/performance/profiling), [languages / python](https://talira.ai/categories/languages/python)
- Platforms: macos, linux, windows, cli
- Licence: MIT
- Pricing: Free and open source
- Free tier: yes
- Self-hostable: yes
- Creator: benfred

py-spy is a sampling profiler that shows what a Python program is spending time on without restarting it or modifying its code. It runs outside the profiled process and is written in Rust for low overhead, so it is safe to attach to production. It can record flame graphs, show a live top-like view, or dump current stack traces, and supports CPython 2.3-2.7 and 3.3-3.15 on Linux, [macOS](https://talira.ai/catalog/macos-8swyggxb.md), Windows and [FreeBSD](https://talira.ai/catalog/freebsd-d628b1cm.md).

## Links

- GitHub: https://github.com/benfred/py-spy

## Ways to install

### Package managers

- [Homebrew](https://talira.ai/catalog/homebrew-djy17yn9.md): <https://formulae.brew.sh/formula/py-spy>[^1]

## Problems it solves

- my Python service in production is slow and I cannot add profiling code
- attach a profiler to an already running Python process by PID
- see a flame graph of where my Python script spends time
- my Python process is stuck, show me what every thread is doing
- cProfile overhead distorts the results
- top-like live view of the hottest Python functions
- profile a Python job inside a Docker container
- find which function is burning CPU in a Django worker

## Features

- attach by PID
- record flame graphs
- top view
- dump stack traces
- low overhead, out of process

## Capabilities

- Has a command line tool: plan not known

## Trust

Overall: 0.65 out of 1.
Signals: maintenance 0.83, adoption 0.84, momentum 0.66, community 0.74, backing 0.20, extensibility 0.20.

- last commit 9 days ago
- 35 commits in the last 90 days
- latest release v0.4.3 21 days ago
- 15.6k GitHub stars
- 69 contributors
- created by benfred

## Alternatives

- [hyperfine](https://talira.ai/catalog/hyperfine-54mq6pqw.md): A command-line benchmarking tool

## Sources

[^1]: https://formulae.brew.sh/api/formula.json (checked 21 Nov 2026)
