Skip to content

globals

globals

Process-wide caches shared by every Tracer.

Tracing a with block means finding its source, parsing it to an AST, and compiling the block body — work that is identical every time the same block is entered. These two module-level dicts memoize that work across all tracer instances so, e.g., a with model.trace(...) inside a Python loop is read, parsed, and compiled exactly once.

Both grow with the number of distinct source files and trace sites seen during the process, which is bounded by the program's own source, so they are never evicted. Neither is re-validated against on-disk changes: a source edited mid-run is still traced as it was first seen (see Tracer.source).

SOURCES module-attribute

SOURCES: dict[str, str] = {}

BLOCKS module-attribute

BLOCKS: dict[tuple[str, int, str, int], tuple[AST | None, CodeType | None]] = {}