Welcome to Pyccolo’s documentation!
Pyccolo (pronounced like the instrument “piccolo”) is a library for declarative instrumentation in Python: you specify the what of the instrumentation you wish to perform, and Pyccolo takes care of the how. It brings metaprogramming to everybody through general, event-emitting AST transformations, and aims to be:
ergonomic — you subclass
pyccolo.BaseTracerand decorate a handler; there’s no bytecode to patch and noast.NodeTransformerto hand-write;composable — layering multiple, independently-written instrumentations usually Just Works (see Composing tracers);
portable — the same code runs across Python 3.6 through 3.14, with few exceptions, because instrumentation is embedded at the level of source code rather than bytecode.
Here is the smallest interesting program: a tracer that prints "Hello,
world!" before every statement that executes.
import pyccolo as pyc
class HelloTracer(pyc.BaseTracer):
@pyc.before_stmt
def handle_stmt(self, *_, **__):
print("Hello, world!")
with HelloTracer:
# prints "Hello, world!" 11 times
pyc.exec("for _ in range(10): pass")
New here? Start with Installation, then walk through
Quickstart. From there, The model: events and handlers is the conceptual
heart of the library. Looking for a specific class or function? Jump to the
API reference, or the Command line interface for the pyc command-line tool.
Getting started
Concepts
Reference
- Command line interface
- Example gallery
- API reference
- History
- 0.0.91 (2026-07-03)
- 0.0.87 (2026-06-24)
- 0.0.86 (2026-06-12)
- 0.0.85 (2026-01-20)
- 0.0.84 (2026-01-19)
- 0.0.83 (2026-01-15)
- 0.0.82 (2026-01-09)
- 0.0.81 (2026-01-08)
- 0.0.80 (2026-01-06)
- 0.0.78 (2026-01-03)
- 0.0.77 (2025-12-26)
- 0.0.76 (2025-12-25)
- 0.0.75 (2025-12-22)
- 0.0.73 (2025-11-21)
- 0.0.72 (2025-04-10)
- 0.0.71 (2025-03-16)
- 0.0.70 (2025-01-04)
- 0.0.69 (2024-12-19)
- 0.0.68 (2024-12-12)
- 0.0.67 (2024-10-13)
- 0.0.66 (2024-10-06)
- 0.0.65 (2024-08-25)
- 0.0.64 (2024-07-21)
- 0.0.63 (2024-07-19)
- 0.0.58 (2024-07-12)
- 0.0.55 (2024-06-24)
- 0.0.54 (2024-02-29)
- 0.0.53 (2024-02-24)
- 0.0.52 (2023-12-21)
- 0.0.51 (2023-12-19)
- 0.0.50 (2023-12-07)
- 0.0.49 (2023-08-19)
- 0.0.48 (2023-07-15)
- 0.0.45 (2023-01-02)
- 0.0.44 (2022-12-14)
- 0.0.43 (2022-12-06)
- 0.0.41 (2022-12-04)
- 0.0.39 (2022-11-19)
- 0.0.38 (2022-10-30)
- 0.0.37 (2022-10-26)
- 0.0.36 (2022-10-24)
- 0.0.35 (2022-08-06)
- 0.0.34 (2022-07-18)
- 0.0.33 (2022-07-12)
- 0.0.32 (2022-07-02)
- 0.0.31 (2022-07-02)
- 0.0.30 (2022-07-02)
- 0.0.28 (2022-05-30)
- 0.0.27 (2022-05-30)
- 0.0.26 (2022-05-21)
- 0.0.25 (2022-04-18)
- 0.0.24 (2022-04-18)
- 0.0.23 (2022-03-18)
- 0.0.22 (2022-03-17)
- 0.0.21 (2022-03-02)
- 0.0.20 (2022-02-14)
- 0.0.19 (2022-02-14)
- 0.0.17 (2022-02-03)
- 0.0.14 (2022-02-02)
- 0.0.13 (2022-01-31)
- 0.0.12 (2022-01-30)
- 0.0.11 (2022-01-30)
- 0.0.10 (2022-01-26)
- 0.0.9 (2022-01-24)
- 0.0.8 (2022-01-23)
- 0.0.7 (2022-01-06)
- 0.0.6 (2022-01-06)
- 0.0.5 (2021-12-29)
- 0.0.4 (2021-12-26)
- 0.0.3 (2021-12-23)
- 0.0.2 (2021-12-22)
- 0.0.1 (2020-10-25)