l>

documentation

Python SDK

Connect to an l server from Python with the PyO3-backed IPC client.

The Python SDK exposes a pure Rust IPC core through PyO3. It handles TCP framing, wire serialization, and LZ4 decompression for Python applications.

l-labs/python_ipc

Install

Install a wheel from the v0.1.0 release:

pip install <wheel>

Start an l server before connecting:

l -p 5001

First query

import l

conn = l.connect("localhost", 5001)
conn.query("t:([]sym:`A`B`A;price:1.5 2.5 3.5)")
print(conn.query("select from t").to_python())
# {'sym': ['A', 'B', 'A'], 'price': [1.5, 2.5, 3.5]}
conn.close()

Connection also works as a context manager. Use connect(host, port, "user:pass") when the server expects credentials.

Queries return K values. Call .to_python() to convert them to Python values, and use K constructors to pass exact l values:

conn.query_with_args("{x+y}", l.K.int(10), l.K.int(32))

Type mapping

l valueTagPython
bool-1 / 1bool / list[bool]
byte-4 / 4int / bytes
short, int, long-5..-7 / 5..7int / list[int]
real, float-8, -9 / 8, 9float / list[float]
char, string-10 / 10str
symbol-11 / 11str / list[str]
temporals-12..-19raw count since 2000.01.01
mixed list0list
table, keyed table98dict of column name to list
dict99dict
null ::101None

Null numerics arrive as sentinels: 0N is -2**31, 0Nj is -2**63, and float nulls are nan. Server errors raise RuntimeError; the connection stays usable afterwards. Use one connection per thread.