Examples¶
Point has two i32 fields. Kiln writes them in that order. Eight little-endian bytes, and no names.
from kiln import Writer, decode, encode
point = ("struct", [("x", ("i32",)), ("y", ("i32",))])
writer = Writer(64)
raw = writer.encode(point, {"x": 9, "y": -4})
print(decode(point, raw), len(raw))
The program prints {'x': 9, 'y': -4} 8.
A tensor directory keeps the numeric payload as the array. The view's data field is a slice of the input buffer.