Registry / observability / yappi
library1.7.6pypypi✓ verified 24d ago

Yappi (Yet Another Python Profiler) is a fast, C-implemented tracing profiler for Python applications, notably supporting multithreaded, asyncio, and gevent code. It overcomes limitations of standard profilers like `cProfile` by offering per-thread CPU time analysis, on-the-fly profiling capabilities, and flexible mechanisms for filtering and sorting profiling results. The library is currently at version 1.7.6 and maintains an active release schedule.

pip install yappi
INSTALL
IMPORT
SIG · YAPPI
Y
yappi
observabilitypythonv1.7.6
Install
1.6s avg
Import
28ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.028s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.028s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

yappi
import yappi
from yappi import _yappi
The `_yappi` module is an internal C implementation detail and should not be imported directly. Attempting to do so or encountering an error related to `_yappi` often indicates an installation issue.

This quickstart demonstrates how to profile a simple Python function using `yappi.start()`, executing the target code, `yappi.stop()`, and then printing function statistics. It also shows how to set the clock type (CPU or Wall time) and clear the collected stats.

import yappi import time def calculate_sum(n): total = 0 for i in range(n): total += i return total def main_task(): time.sleep(0.1) # Simulate some I/O or other work result = calculate_sum(1_000_000) time.sleep(0.05) return result # Start profiling yappi.set_clock_type("cpu") # Can be "wall" for wall time yappi.start() # Run the code to be profiled main_task() # Stop profiling and print statistics yappi.stop() # Get function statistics and print them func_stats = yappi.get_func_stats() print("Function Statistics:") func_stats.print_all( columns={0:('ncall', 5), 1:('tottime', 8), 2:('avgtime', 8), 3:('file', 30)}, sort_type='tottime' ) # Clear collected statistics yappi.clear_stats()
yappi --version
Debug
Known issues
breakingOlder versions of Yappi (pre-1.x) supported Python 2.6.x up to 3.4. Recent versions (from 1.7.0 onwards) officially support Python 3.6 and higher, including Python 3.14. Users on older Python 2 or early Python 3 versions will need to use an older Yappi release or upgrade their Python interpreter.
fix
Upgrade Python to 3.6+ or downgrade Yappi to a compatible older version if strict Python version requirements exist.
affects: <1.7.0
gotchaYappi operates as a per-interpreter resource. Attempting to run multiple Yappi profiler instances within the same Python interpreter concurrently will raise an exception.
fix
Ensure only one `yappi.start()` is active at any given time per interpreter. Use `yappi.stop()` and `yappi.clear_stats()` between profiling sessions if necessary.
affects: All
gotchaWhen interpreting profiling results, distinguish between 'tottime' and 'tsub'. 'tottime' (total time) includes time spent in sub-functions called from the profiled function, while 'tsub' (subtime) represents time spent directly within the function itself, excluding its sub-calls.
fix
Understand the definitions: `tottime` is cumulative, `tsub` is self-time. Choose the appropriate metric based on whether you want to identify bottlenecks within a function's own execution or its entire call graph.
affects: All
gotchaBy default, Yappi profiles using 'CPU time'. For I/O-bound or concurrent applications (e.g., asyncio, gevent), 'Wall time' might be more relevant to capture actual elapsed time, including waits.
fix
Explicitly set the clock type using `yappi.set_clock_type("wall")` before starting the profiler if Wall time is desired. Default is `"cpu"`.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'yappi'
The 'yappi' library is not installed in the current Python environment or the environment where the script is being executed.
fix
Run `pip install yappi` in your terminal to install the library.
fatal error: Python.h: No such file or directory
During installation, the C compiler cannot find the Python development headers required to build the 'yappi' C extension.
fix
On Debian/Ubuntu, install `python3-dev` using `sudo apt-get install python3-dev`. On Fedora, use `sudo dnf install python3-devel`. On macOS with Homebrew, ensure Python is installed with development headers (usually default).
error: Microsoft Visual C++ 14.0 or greater is required.
On Windows, installing 'yappi' requires a C compiler, specifically the Microsoft Visual C++ build tools, which are missing from your system.
fix
Install the Microsoft Visual C++ Build Tools from the official Visual Studio download page (look for 'Build Tools for Visual Studio') and ensure the 'Desktop development with C++' workload is selected.
AttributeError: 'YStat' object has no attribute 'save'
The `save()` method, which exports profiling data, belongs to the `YFuncStats` or `YThreadStats` collection object, not to individual `YStat` objects within that collection.
fix
Call `save()` directly on the `YFuncStats` object returned by `yappi.get_func_stats()` (e.g., `stats = yappi.get_func_stats(); stats.save('profile.txt', type='callgrind')`).
Upgrade
Version history
1.7.6latest on PyPI · released Mar 17, 2026
Audit
Dependencies
pythonrequiredRequired Python version.
Agent activity
38 hits · last 30 days
node
30
Amazon
1
OpenAI (training)
1
Resources