pyccolo
Declarative instrumentation for Python
Decision gist · record as of 2026-08-14
Yes, with conditions. Pyccolo is actively maintained, has no known vulnerabilities, and installs with minimal friction. It is genuinely useful for building observability and syntax-augmentation tools that would otherwise require manual bytecode patching or complex AST visitor logic. However, it is classified as Alpha, so production use should account for potential API changes. Start with it if you need composable, source-level instrumentation; avoid it if you need guaranteed stability or are looking for a simple logging library.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Code to be instrumented must be passed to pyc.exec() or imported inside a tracing context; source code at module level where the tracer class is defined will not be instrumented unless quoted.
- Low friction: pure Python wheel with only two lightweight runtime dependencies (traitlets and typing_extensions).
- Active maintenance with a recent release 34 days ago and ongoing repository activity.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive; you can use, modify, and distribute Pyccolo with minimal restrictions, provided you include the license notice.
last release 2026-07-11 (34 days) · last repo commit 2026-08-13 · 104 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 222,978 downloads/mo, #9,254 on PyPI
Alternatives
Verify before relying
pip install pyccolo
import pyccolo as pyc
class HelloTracer(pyc.BaseTracer):
@pyc.before_stmt
def handle_stmt(self, *_, **__):
print("Hello, world!")
with HelloTracer:
pyc.exec("for _ in range(10): pass")- Performance overhead of AST transformation and event emission at runtime compared to uninstrumented code.
- Compatibility edge cases or limitations across the stated Python 3.6–3.14 range beyond the general claim of portability.
- Maturity and stability guarantees given the Alpha development status classification.
What it is and what it does
Pyccolo is a metaprogramming library that instruments Python code by rewriting its abstract syntax tree to emit fine-grained events—over 100 event types covering statements, attribute access, operators, assignments, literals, calls, and returns. Instead of manually patching bytecode or writing ast.NodeTransformer classes, you subclass BaseTracer, decorate handler methods with event decorators like @pyc.before_stmt or @pyc.after_assign_rhs, and register them to observe or modify behavior. Handlers receive the instrumented value, AST node, stack frame, and event object, and can override the value that flows out of an expression by returning a replacement.
The library is designed to be ergonomic, composable, and portable. Multiple independently-written tracers can be nested in context managers and their handlers compose automatically without manual conflict resolution. Because instrumentation is embedded at the source level rather than bytecode, the same code runs across Python 3.6 through 3.14. It powers production tools like ipyflow (a reactive Jupyter kernel), pipescript (pipe operators and macros for IPython), and pycograd (automatic differentiation for plain numpy code), and has been used to build code coverage, syntactic macros, optional chaining, lazy imports, and concolic execution tools.
Use it for
- Build a reactive notebook kernel that tracks dataflow between cells by instrumenting variable assignments and attribute access.
- Implement statement-level code coverage by registering a handler on before_stmt to log which lines execute.
- Add syntax extensions like pipe operators or optional chaining by defining an AugmentationSpec and attaching handlers to the resulting AST nodes.
- Trace computation graphs for automatic differentiation by intercepting operations on ordinary numpy arrays without requiring a special namespace.
- Instrument imports to implement lazy loading or concolic execution by hooking module load events.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
Pyccolo is actively maintained, has no known vulnerabilities, and installs with minimal friction. It is genuinely useful for building observability and syntax-augmentation tools that would otherwise require manual bytecode patching or complex AST visitor logic. However, it is classified as Alpha, so production use should account for potential API changes. Start with it if you need composable, source-level instrumentation; avoid it if you need guaranteed stability or are looking for a simple logging library.
Install
pyccolo on PyPI
Before you install
Low friction: pure Python wheel with only two lightweight runtime dependencies (traitlets and typing_extensions). Active maintenance with a recent release 34 days ago and ongoing repository activity.
Code to be instrumented must be passed to pyc.exec() or imported inside a tracing context; source code at module level where the tracer class is defined will not be instrumented unless quoted.
License in practice
BSD-3-Clause is permissive; you can use, modify, and distribute Pyccolo with minimal restrictions, provided you include the license notice.
Quickstart
pip install pyccolo
import pyccolo as pyc
class HelloTracer(pyc.BaseTracer):
@pyc.before_stmt
def handle_stmt(self, *_, **__):
print("Hello, world!")
with HelloTracer:
pyc.exec("for _ in range(10): pass")
Verify before relying
- Performance overhead of AST transformation and event emission at runtime compared to uninstrumented code.
- Compatibility edge cases or limitations across the stated Python 3.6–3.14 range beyond the general claim of portability.
- Maturity and stability guarantees given the Alpha development status classification.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagestraitletstyping_extensions |
| Maintenance | Actively maintained 34 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 222,978 / month, #9,254 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: pyccolo-0.0.94-py2.py3-none-any.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 › “python ast instrumentation”
- pyccoloPyccolo is a library for declarative instrumentation in Python that…
- astunparseConverts Python abstract syntax trees (ASTs) back into source code…
- ast-decompilerConverts Python abstract syntax trees (ASTs) back into readable…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also google-pasta · ipyflow-core · aiocop · pycnite · dncil · diastatic-malt · llama-index-instrumentation · ast-grep-py · Rx · logfury