pyinstrument
Call stack profiler for Python. Shows you why your code is slow!
Decision gist · record as of 2026-08-14
Yes. Pyinstrument is actively maintained, has no known vulnerabilities, carries a permissive license, and solves a real problem—finding performance bottlenecks—with a low-friction install and intuitive API. The medium install friction is offset by broad platform coverage and the value of its output formats. Recommended for any Python developer doing performance optimization.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8 or later; profiling inside Docker containers may produce inaccurate results due to slow gettimeofday syscalls.
- Medium install friction due to compiled wheels for multiple platforms and Python versions (3.10–3.12 covered); active maintenance with a release 16 days ago and 8001 repository stars suggest reliable upkeep.
License · maintenance · safety
permissive license (permissive) — Permissive license (BSD) allows use in commercial and proprietary projects with minimal restrictions.
last release 2026-07-29 (16 days) · last repo commit 2026-08-04 · 8,001 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 10,935,462 downloads/mo, #1,425 on PyPI
Alternatives
Verify before relying
pip install pyinstrument
from pyinstrument import Profiler
profiler = Profiler()
profiler.start()
# ... code to profile ...
profiler.stop()
print(profiler.output_text())- Whether the HTML renderer's interactive timeline and flat-list output modes are stable across all supported Python versions.
- Performance overhead of the timing thread option on systems with slow timers.
- Compatibility with pickle-serialized classes when using the CLI profiler.
What it is and what it does
Pyinstrument is a statistical profiler that periodically samples your Python program's call stack to measure where time is spent. Unlike deterministic profilers that instrument every function call, pyinstrument uses sampling to keep overhead low while still identifying the slowest parts of your code. It supports multiple output formats: a hierarchical text tree view for the terminal, an interactive HTML report with timeline and call-stack navigation, and integration with Jupyter notebooks via a magic command.
The package is designed for developers who need to optimize slow Python code but want a tool that's easy to use and doesn't require extensive instrumentation. It works with modern Python versions (3.8+) and includes integrations for Django, FastAPI, Litestar, and aiohttp. Recent versions added a context-manager and decorator API for profiling specific code blocks, plus lower-overhead timing options for environments like Docker where syscall-based timers are slow.
Use it for
- Profile a web application request to find which handler or middleware is causing latency.
- Identify the slowest function in a data-processing pipeline before optimizing it.
- Profile a Jupyter notebook cell to understand where computation time is spent during analysis.
- Integrate profiling into a Django or FastAPI application to capture production performance issues.
- Use the decorator API to profile individual functions or methods without modifying surrounding code.
- Export HTML reports to share performance analysis with team members or stakeholders.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Pyinstrument is actively maintained, has no known vulnerabilities, carries a permissive license, and solves a real problem—finding performance bottlenecks—with a low-friction install and intuitive API. The medium install friction is offset by broad platform coverage and the value of its output formats. Recommended for any Python developer doing performance optimization.
Install
pyinstrument on PyPI
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions (3.10–3.12 covered); active maintenance with a release 16 days ago and 8001 repository stars suggest reliable upkeep.
Requires Python 3.8 or later; profiling inside Docker containers may produce inaccurate results due to slow gettimeofday syscalls.
License in practice
Permissive license (BSD) allows use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install pyinstrument
from pyinstrument import Profiler
profiler = Profiler()
profiler.start()
# ... code to profile ...
profiler.stop()
print(profiler.output_text())
Verify before relying
- Whether the HTML renderer's interactive timeline and flat-list output modes are stable across all supported Python versions.
- Performance overhead of the timing thread option on systems with slow timers.
- Compatibility with pickle-serialized classes when using the CLI profiler.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 16 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,935,462 / month, #1,425 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Environment :: ConsoleEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIXTopic :: Software Development :: DebuggersTopic :: Software Development :: Testing |
Evidence: pyinstrument-5.1.3-cp310-cp310-macosx_10_9_universal2.whl; pyinstrument-5.1.3-cp310-cp310-macosx_11_0_arm64.whl; pyinstrument-5.1.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyinstrument-5.1.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyinstrument-5.1.3-cp310-cp310-musllinux_1_2_aarch64.whl; pyinstrument-5.1.3-cp310-cp310-musllinux_1_2_x86_64.whl; pyinstrument-5.1.3-cp310-cp310-win32.whl; pyinstrument-5.1.3-cp310-cp310-win_amd64.whl; pyinstrument-5.1.3-cp311-cp311-macosx_10_9_universal2.whl; pyinstrument-5.1.3-cp311-cp311-macosx_11_0_arm64.whl; pyinstrument-5.1.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyinstrument-5.1.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyinstrument-5.1.3-cp311-cp311-musllinux_1_2_aarch64.whl; pyinstrument-5.1.3-cp311-cp311-musllinux_1_2_x86_64.whl; pyinstrument-5.1.3-cp311-cp311-win32.whl; pyinstrument-5.1.3-cp311-cp311-win_amd64.whl; pyinstrument-5.1.3-cp312-cp312-macosx_10_13_universal2.whl; pyinstrument-5.1.3-cp312-cp312-macosx_11_0_arm64.whl; pyinstrument-5.1.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyinstrument-5.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “call stack profiler”
- pyinstrumentPyinstrument is a statistical call-stack profiler that samples your…
- memrayMemray is a memory profiler for Python that traces every function…
- snakevizSnakeViz is a web-based viewer for Python profiling data that…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also fastapi-profiler · line-profiler · py-spy · tuna · memray · yappi · xprof · pyroscope-io · scalene · pyprof2calltree