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_ipcInstall
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 value | Tag | Python |
|---|---|---|
| bool | -1 / 1 | bool / list[bool] |
| byte | -4 / 4 | int / bytes |
| short, int, long | -5..-7 / 5..7 | int / list[int] |
| real, float | -8, -9 / 8, 9 | float / list[float] |
| char, string | -10 / 10 | str |
| symbol | -11 / 11 | str / list[str] |
| temporals | -12..-19 | raw count since 2000.01.01 |
| mixed list | 0 | list |
| table, keyed table | 98 | dict of column name to list |
| dict | 99 | dict |
null :: | 101 | None |
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.