GitHub

jit_compiler

API reference for jit_compiler.

Schema decoders generated as Python source at run time (Effect's SchemaJITCompiler).

enable(ast) compiles an AST and the nodes its parsers reach; importing pyfect.schema.jit_compiler.install compiles every AST resolved after the import. Each operation is generated on first use and compiled with exec; when exec is unavailable or generation fails, parsing stays with the interpreter. Errors raised while parsing are never retried.

Functions

compiler

compiler(ast, resolve) -> DecoderSource | None

The lazily generated operations of ast, or None when compiling it cannot beat the interpreter or exec is unavailable.

ParameterTypeDescription
astAST
resolveResolve

Returns DecoderSource | None

def compiler(ast: AST, resolve: Resolve) -> DecoderSource | None:
    """The lazily generated operations of ``ast``, or ``None`` when
    compiling it cannot beat the interpreter or ``exec`` is unavailable."""
    if not codegen.should_compile_parser(ast) or not _supported():
        return None
    return _Lazy(ast, resolve)

enable

enable(ast) -> None

Compile ast and its parsing dependencies on first use (Effect's SchemaJITCompiler.enable). Enable before the first parse: parsers that already resolved an entry keep it. The type side and the flipped AST are separate ASTs; enable them separately.

ParameterTypeDescription
astAST
def enable(ast: AST, /) -> None:
    """Compile ``ast`` and its parsing dependencies on first use (Effect's
    ``SchemaJITCompiler.enable``). Enable before the first parse: parsers
    that already resolved an entry keep it. The type side and the flipped
    AST are separate ASTs; enable them separately."""
    _enable(ast, compiler)

Modules