Yappi

A fast tracing Python profiler that is multithreading, asyncio, and gevent aware.

Library
PyPI
v1.7.6
1,725stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
56/100Fair
Development Activity48
Maintenance36
Community52
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture85
Code Quality84
Innovation82
Learning Curve80

Yappi (Yet Another Python Profiler) is a tracing profiler for CPython that understands concurrency. Unlike the standard-library profilers, it correctly attributes CPU and wall-clock time across threads, asyncio coroutines, and gevent greenlets, so you can profile real concurrent applications without losing or misattributing time.

Implemented largely in C for low overhead, Yappi is imported into your program and controlled through a small API: start and stop profiling, then retrieve per-function and per-thread statistics that can be filtered, sorted, saved, and exported to callgrind or pstat formats for tools like KCachegrind and snakeviz. It supports both CPU-time and wall-time clocks, making it suitable for pinpointing both compute-bound and I/O-bound hotspots.

What You Get

  • A tracing profiler that separates timing per thread, coroutine, and greenlet
  • Selectable CPU-time and wall-clock timing modes
  • Function and thread statistics with sorting, filtering, and clearing
  • Export to callgrind and pstat formats for KCachegrind, snakeviz, and pstats
  • A low-overhead C core suitable for profiling production-like workloads

Common Use Cases

  • Profiling multithreaded Python services to find CPU hotspots per thread
  • Measuring where time goes in asyncio or gevent applications
  • Distinguishing I/O wait from compute using wall vs CPU clocks
  • Exporting profiles to callgrind/pstat for visualization in external tools

Under The Hood

Architecture - The yappi/ package pairs a thin Python API (yappi.py) with a C extension core (_yappi.c) plus supporting C modules for call-stack tracking (callstack.c), timing (timing.c), thread-local storage (tls.c), a hash table (hashtab.c), and a freelist allocator (freelist.c). The C layer installs interpreter hooks and maintains per-context call graphs, which the Python layer exposes as function and thread stats objects.

Tech Stack - CPython C extension built via setup.py/pyproject.toml, with the public interface in pure Python. It targets modern CPython and integrates with asyncio and gevent context tracking.

Code Quality - The repo carries an extensive test suite under tests/ (async generators, context vars, asyncio context managers, and more) plus a CHANGELOG and manual test harnesses. The C core is modular and long-established, though maintenance cadence is intermittent.

API Design - The API is small and discoverable: module-level start/stop/clear_stats plus get_func_stats/get_thread_stats returning chainable, sortable stat collections. Clock selection and export helpers keep common workflows to a few lines, making it approachable despite the C internals.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search