Language neutrality¶
A reusable capability block's code is Python, and its interface is expressed in XCI's own types. The interface is what crosses the block's boundary, so it is the one description that the Rust kernel, other blocks and your Python code all read. Inside the block you keep using any Python library you like.
Why the interface has its own types¶
- The kernel reads it. The kernel is written in Rust and checks every call against the interface before the call reaches your code.
- Callers come from anywhere. A workflow step, another block, or a block on another runtime provider calls your methods through the interface, whatever it was written in.
- A value means one thing. Every XCI type states its size and unit:
u64is an unsigned 64-bit integer, adecimalstates its precision and scale, and atimestampstates its unit. A Pythonintorfloatcarries none of that, so two callers could otherwise read the same value differently.
One interface, code for each side¶
The block pipeline compiles your block's interface once and generates code for each side of the boundary. A charge request in the ledger block becomes a Python class your block uses:
@dataclass(frozen=True, slots=True)
class ChargeRequest:
account: str # field id 1
amount: int # field id 2
and the matching Rust type the kernel side uses:
Both come from the one interface, and both are regenerated whenever the interface changes, so the two sides always agree. See Generated bindings.
What stays in Python¶
Only what crosses the interface is typed in XCI. A DataFrame, a model, or a client session stays inside the block that created it, and callers receive typed values. See Any Python library and Framework objects.