You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Perf: REST has no pluggable JSON loader — orjson cannot speed up list parsing #260
REST response parsing is locked to httpx's stdlib response.json(). List endpoints (markets.list_all, trades.list_all, fcm.orders) return thousands of rows where parsing dominates wall time; orjson would cut REST list latency 2-3x but there is no opt-in. Inconsistent with the WS hot path which already accepts ws_json_loads (#209).
kalshi/_base_client.py:67 — transport .json() usage
Evidence
# config.py docstring:
ws_json_loads: Optional callable used to parse WS frames. ``None``
falls back to :func:`json.loads`. Set to e.g. ``orjson.loads``
for ~2-3x faster recv-loop parsing on high-volume streams.
# resources/_base.py:
result: dict[str, Any] = response.json()
return result
Recommended fix
Add rest_json_loads: Callable[[bytes], Any] | None = None to KalshiConfig and use it in _get/_post/_list (replace response.json() with loader(response.content) when set). Add a small bench variant of bench_request_hot_path.py parametrized on the loader.
Activity
feat(rest): pluggable JSON loader + plumb extra_headers through resou…