pyccolo

Getting started

  • Installation
  • Quickstart

Concepts

  • The model: events and handlers
  • Composing tracers
  • Conditional handlers and predicates
  • Syntax augmentation
  • Source-to-source: transform, untransform, and pure mode
  • Compatibility with sys.settrace
  • Instrumenting imported modules
  • Performance and guards

Reference

  • Command line interface
  • Example gallery
    • In the wild
  • API reference
  • History
pyccolo
  • Example gallery
  • View page source

Example gallery

Each of the following ships under pyccolo/examples/ as a self-contained, tested tracer — great starting points to adapt.

Example

Demonstrates

coverage.py

statement-level code coverage (before_stmt, should_instrument_file)

optional_chaining.py

?., .?, ?? optional chaining / nullish coalescing via AugmentationSpec

pipeline_tracer.py

|> / |>> pipeline operators (binop augmentation)

quick_lambda.py

MacroPy-style f[_ + _] quick lambdas

quasiquote.py

MacroPy-style q[...] / u[...] quasiquotes

block_lambda.py, func_block.py, brace_subscript.py

statement-bodied name{ ... } blocks (paired-delimiter augmentation)

lazy_imports.py

make (most) imports lazy, resolving on first use

future_tracer.py

implicit async: run assignments on a thread pool, unwrap futures on use

concolic.py

concolic (concrete + symbolic) execution with a Z3 / brute-force solver

In the wild

Beyond the bundled examples, Pyccolo is the instrumentation engine behind several larger projects — good places to see what it can do at scale:

  • ipyflow — a reactive Python kernel for Jupyter that tracks dataflow between cells using Pyccolo’s dynamic analysis.

  • pipescript — a pipe operator (|>), placeholder ($), and macro syntax for IPython/Jupyter, built entirely on Pyccolo’s syntax augmentation and composable event handlers.

  • pycograd — a small reverse-mode automatic-differentiation library that differentiates ordinary numpy code (no special “autodiff namespace”), using Pyccolo to trace the computation.

People have also built statement-level coverage, syntactic macros (quasiquotes, quick lambdas), syntax-augmented Python (optional chaining, pipeline operators), lazy imports, concolic execution, and tools to uncover semantic memory leaks.

Previous Next

© Copyright 2020, Stephen Macke.

Built with Sphinx using a theme provided by Read the Docs.