Sigil is an intermediate representation that transpiles to Python. Same semantics, fraction of the tokens.
import json
def safe_parse(text: str) -> dict:
try:
result = json.loads(text)
return result
except json.JSONDecodeError:
return {}
except TypeError:
return {}<json>
@safe_parse text:s>{} = !{json.loads text}~>{{}}The problem
Every token costs money. In agentic workflows that generate hundreds of functions, verbose Python burns through budgets fast.
Code accumulates in conversation history. Python's verbosity eats context that should go to reasoning.
LLMs don't need def, return, or try/except spelled out. They parse denser notation just as well.
How it works
Sigil is not an execution target. It compiles to clean Python.
Token-dense notation with zero ambiguity.
@clamp x:f lo:f hi:f>f = x<lo ? lo : x>hi ? hi : x
Tree-sitter parser, IR, Python AST. One command.
$ sigil transpile clamp.sigil --> clamp.py
Clean, idiomatic output. Zero runtime overhead.
def clamp(x: float, lo: float,
hi: float) -> float:
return lo if x < lo else \
hi if x > hi else xBenchmarks
Examples
def safe_div(a: float, b: float) -> float:
try:
return a / b
except ZeroDivisionError:
return 0.0@safe_div a:f b:f>f = !{a/b}~>{0.0}def average(ns: list[float]) -> float:
return sum(ns) / len(ns)@average [f]>f = +$/# $
def evens(ns: list[int]) -> list[int]:
return list(filter(
lambda x: x % 2 == 0, ns))@evens ns:[i]>[i] = ns|\x->x%2==0