Hacker News

Show HN: Ibex a C++ engine for Polars and standalone DSL

IbexEngine for Polars

ibex-polars is an experimental Polars execution engine. Polars builds and optimizes the plan as usual, Ibex executes it, and the result is a Polars DataFrame. You select it with one argument to collect.

Usage

The query itself does not change. The engine is chosen when the query is collected.

Polars engine:

import polars as pl
query = (
  pl.scan_parquet("trades.parquet")
  .filter(pl.col("qty") > 10)
  .group_by("symbol", "day")
  .agg(avg_price=pl.col("price").mean())
)
df = query.collect()

IbexEngine:

import polars as pl
from ibex_polars import IbexEngine
query = (
  pl.scan_parquet("trades.parquet")
  .filter(pl.col("qty") > 10)
  .group_by("symbol", "day")
  .agg(avg_price=pl.col("price").mean())
)
# returns a pl.DataFrame
df = query.collect(engine=IbexEngine())

pl.Config.set_engine_affinity(IbexEngine()) makes Ibex the default for lazy collection, and sink_parquet(path, engine=engine) streams results straight to a file.

Benchmarks

Both suites use their published Polars code, unchanged. Each lazy query is collected on Polars 2.2.0's streaming engine and on IbexEngine with the same thread budget, and each result is checked against Polars before timing.

Results vary by query: Ibex is ahead on most grouped aggregations, roughly level on PDS-H, and behind on several joins at eight cores. Each value is IbexEngine time divided by Polars streaming time: below 1 means Ibex is faster.

Suite summary (geometric means):

Suite 8 cores Faster 1 core Faster
PDS-H, SF 10 0.95 11/22 0.92 14/22
h2o groupby 0.62 42/50 0.45 45/50
h2o joins 1.13 2/5 0.79 4/5

h2o joins:

Question 8 cores 1 core
q1 small inner on int 1.48 1.00
q2 medium inner on int 1.51 1.09
q3 medium left on int 0.77 0.58
q4 medium inner on factor 1.36 0.95
q5 big inner on int 0.80 0.50

PDS-H, scale factor 10:

Query 8 cores 1 core Query 8 cores 1 core
Q01 0.97 0.84 Q12 0.96 0.98
Q02 0.84 1.07 Q13 0.72 0.67
Q03 0.97 0.94 Q14 1.09 0.98
Q04 1.00 1.14 Q15 0.98 0.96
Q05 1.04 0.97 Q16 1.37 1.15
Q06 0.90 0.91 Q17 1.04 1.05
Q07 1.05 0.94 Q18 0.59 0.52
Q08 1.05 0.99 Q19 1.00 1.04
Q09 1.14 1.01 Q20 0.86 0.85
Q10 0.81 0.75 Q21 1.13 1.00
Q11 0.71 0.75 Q22 1.02 1.15

h2o groupby, 10M rows: 8 cores / 1 core per data shape:

Question K=1e2 K=1e2, 5% NA K=1e2, sorted K=1e1 K=2e0
q1 sum v1 by id1 0.32 / 0.17 0.52 / 0.38 0.58 / 0.52 0.41 / 0.19 0.38 / 0.24
q2 sum v1 by id1:id2 0.53 / 0.26 0.63 / 0.51 0.65 / 0.37 0.37 / 0.16 0.37 / 0.19
q3 sum v1, mean v3 by id3 0.77 / 0.39 0.84 / 0.49 0.81 / 0.39 0.70 / 0.32 0.91 / 0.46
q4 mean v1:v3 by id4 0.61 / 0.36 0.67 / 0.53 0.57 / 0.36 0.67 / 0.36 0.80 / 0.50
q5 sum v1:v3 by id6 0.70 / 0.42 0.76 / 0.50 0.71 / 0.42 0.77 / 0.51 0.90 / 0.68
q6 median, sd v3 by id4:id5 0.55 / 0.51 0.62 / 0.56 0.57 / 0.52 0.37 / 0.52 0.46 / 0.74
q7 max v1 - min v2 by id3 0.99 / 0.49 1.07 / 0.60 1.00 / 0.51 0.91 / 0.47 0.99 / 0.58
q8 largest two v3 by id6 0.30 / 0.45 0.30 / 0.55 0.30 / 0.44 0.13 / 0.27 0.06 / 0.18
q9 regression v1, v2 by id2:id4 0.62 / 0.42 0.77 / 0.52 0.76 / 0.44 0.88 / 0.43 1.35 / 0.46
q10 sum v3, count by id1:id6 1.10 / 1.09 1.19 / 1.20 1.17 / 1.12 1.17 / 1.09 1.17 / 1.24

Ibex is faster on 42 of 50 cases on eight cores and 45 of 50 on one. The question grouping by all six id columns is slower on both.

Summed medians over all 22 queries, against 6.83 s for Polars streaming; 43.0 s against 47.7 s on one core. Ibex is faster on 11 of 22 queries on eight cores.

On eight cores the small and medium inner joins are slower than Polars, mostly in building the result; on one core Ibex is faster on four of five.

Published v0.5.4 ibex-polars wheel (what pip install gives you) against Polars 2.2.0 streaming with Categorical keys, measured 2026-12-04 on an Intel i7-13700 locked at 3.2 GHz. Both engines get the same budget (IBEX_CORES and POLARS_MAX_THREADS), pinned one thread per physical core.

PDS-H Q16 has an upstream bug that is corrected for both engines. Full method, per-query detail and reproduction commands: performance summary ↗. Run python/bench_polars_engines.sh to measure on your own machine.

How it works

Your lazy query goes through Polars' own optimizer: predicate and projection pushdown and common-subplan elimination. A version-pinned adapter turns the optimized plan into a typed Ibex program; literals are passed as typed bindings. engine.explain(query) prints the program.

The whole query runs in one native call on Ibex's C++ engine, with the GIL released, and comes back as a Polars DataFrame with Polars' dtypes, null semantics and row order.

Details

NotImplementedError before execution, naming the construct. Wrap a Python function with ibex_polars.udf and it runs inside the native query, on several threads when it is elementwise and releases the GIL. Polars' own map_batches and map_elements are not supported.

Python UDFs → Supported areas include equality and as-of joins, window functions with over and order_by, rolling sums, means, extrema and ranks, group_by_dynamic bars, quantiles, regex search, Datetime with time zones, and local Parquet. Several areas, such as pivots, list and struct columns and remote files, are not supported yet. Full coverage table →

Install

Prebuilt wheels for Python 3.11-3.14 on Linux x86_64, Windows x86_64 and macOS on Apple silicon. No compiler needed; the wheel pulls in polars==2.2.0, pyarrow and numpy.

1 - install pip install ibex-polars --find-links https://github.com/bobjansen/Ibex/releases/expanded_assets/v0.6.0
2 - collect on Ibex, falling back to Polars explicitly

from ibex_polars import IbexEngine
engine = IbexEngine()
try:
    df = query.collect(engine=engine)
except NotImplementedError:
    # raised before anything runs
    df = query.collect(engine="streaming")

Questions

No. Imports and query bodies stay as they are; the PDS-H and h2o numbers above come from the suites' own Polars code. You choose the engine at collect or set it once with pl.Config.set_engine_affinity.

collect raises NotImplementedError before any data is touched, naming what it could not translate. Nothing falls back behind your back, so a result from IbexEngine is always an Ibex result. Catch the error to hand the query to Polars explicitly.

No, and the charts above show where. Grouped aggregation is where Ibex gains most. On eight cores the small and medium h2o inner joins and a handful of PDS-H queries (Q16, Q09, Q21) are still slower than Polars, as is the h2o question that groups by all six id columns.

Exactly Polars 2.2.0. The adapter reads Polars' internal plan format, which can change between releases, so each ibex-polars release pins the version it was validated against and refuses others explicitly.

It is experimental. It runs real benchmark suites with identical answers and is checked against Polars' own tests, but the supported surface is still growing. Start with the queries that matter most to you and keep Polars as the explicit backstop.

Ibex, including ibex-polars, is licensed under the Apache License 2.0. See LICENSING.md ↗.

Comments

Read on Hacker News ↗ ← Back to News

Comments

No comments yet. Start the discussion.