Skip to content

base

base

Base backend for compiling traced code.

This module provides the foundational Backend class that handles the compilation of captured source code into executable functions. It serves as the bridge between the tracing system and actual code execution.

Backend

Base backend for compiling traced code into executable functions.

This class handles the core compilation process that transforms captured source code from the tracer into callable Python functions. It provides the foundation for different execution strategies while maintaining a consistent interface.

The compilation process: 1. Formats the source code with proper indentation for function bodies 2. Calls tracer.compile() to wrap code in a function definition
3. Compiles the source code into a Python code object 4. Executes the function definition to create the callable 5. Returns the compiled function for execution

This backend can be subclassed to implement different execution strategies such as remote execution, GPU execution, or specialized environments.

__call__

__call__(tracer: Tracer)

Compile the traced code into an executable function.

Takes the captured source code from the tracer and transforms it into a callable Python function that can be executed with the original context.

PARAMETER DESCRIPTION
tracer

Tracer instance containing the captured code and context

TYPE: Tracer

RETURNS DESCRIPTION

Callable function that executes the traced code block