IbexEngine for Polars

Run Polars queries on Ibex

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.

0.45× of Polars streaming time on the h2o groupby suite, one core (0.62× on eight)
22 / 22 PDS-H queries supported, with results matching Polars
2,320 of 3,519 queries from Polars' test suite run with matching results; the rest are refused
Pinned to Polars 2.2.0, because the adapter reads Polars' internal plan format

Choosing the engine

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.

Results against Polars streaming

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.

h2o groupby, 10M rows, ten questions, 1 core

All figures as tables

Each value is IbexEngine time divided by Polars streaming time: below 1 means Ibex is faster.

Suite summary (geometric means)

Suite8 coresFaster1 coreFaster
PDS-H, SF 100.9511/220.9214/22
h2o groupby0.6242/500.4545/50
h2o joins1.132/50.794/5

h2o joins

Question8 cores1 core
q1 small inner on int1.481.00
q2 medium inner on int1.511.09
q3 medium left on int0.770.58
q4 medium inner on factor1.360.95
q5 big inner on int0.800.50

PDS-H, scale factor 10

Query8 cores1 coreQuery8 cores1 core
Q010.970.84Q120.960.98
Q020.841.07Q130.720.67
Q030.970.94Q141.090.98
Q041.001.14Q150.980.96
Q051.040.97Q161.371.15
Q060.900.91Q171.041.05
Q071.050.94Q180.590.52
Q081.050.99Q191.001.04
Q091.141.01Q200.860.85
Q100.810.75Q211.131.00
Q110.710.75Q221.021.15

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

QuestionK=1e2K=1e2, 5% NAK=1e2, sortedK=1e1K=2e0
q1 sum v1 by id10.32 / 0.170.52 / 0.380.58 / 0.520.41 / 0.190.38 / 0.24
q2 sum v1 by id1:id20.53 / 0.260.63 / 0.510.65 / 0.370.37 / 0.160.37 / 0.19
q3 sum v1, mean v3 by id30.77 / 0.390.84 / 0.490.81 / 0.390.70 / 0.320.91 / 0.46
q4 mean v1:v3 by id40.61 / 0.360.67 / 0.530.57 / 0.360.67 / 0.360.80 / 0.50
q5 sum v1:v3 by id60.70 / 0.420.76 / 0.500.71 / 0.420.77 / 0.510.90 / 0.68
q6 median, sd v3 by id4:id50.55 / 0.510.62 / 0.560.57 / 0.520.37 / 0.520.46 / 0.74
q7 max v1 - min v2 by id30.99 / 0.491.07 / 0.601.00 / 0.510.91 / 0.470.99 / 0.58
q8 largest two v3 by id60.30 / 0.450.30 / 0.550.30 / 0.440.13 / 0.270.06 / 0.18
q9 regression v1, v2 by id2:id40.62 / 0.420.77 / 0.520.76 / 0.440.88 / 0.431.35 / 0.46
q10 sum v3, count by id1:id61.10 / 1.091.19 / 1.201.17 / 1.121.17 / 1.091.17 / 1.24
0.62× / 0.45×

h2o groupby, 8 / 1 cores

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.

6.53 s

PDS-H total, 8 cores

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.

1.13× / 0.79×

h2o joins, 8 / 1 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.

From Polars plan to native execution

Polars builds the plan

Your lazy query goes through Polars' own optimizer: predicate and projection pushdown and common-subplan elimination.

Ibex translates it

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.

Native code executes it

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.

Performance and correctness

Performance

Where the time goes

  • Single-core throughput is the focus; multi-core scaling is still being extended, which is why some gaps are larger at eight cores.
  • Dedicated kernels for paired statistics, top-k per group and ordered first/last.
  • Categorical keys are processed as codes rather than strings.
  • Shared subplans run once per collection (PDS-H Q22: 379 ms to 214 ms on eight cores).
  • Prepared plans are cached, so repeated collects skip translation.
Correctness

Unsupported plans fail early

  • There is no automatic fallback: a plan Ibex cannot translate raises NotImplementedError before execution, naming the construct.
  • Of 3,519 queries from ten Polars test modules, 2,320 run with results matching Polars, 1,199 are refused, and none currently produces a different result.
  • The adapter follows Polars semantics for null-first sorting, NaN ordering, narrow-integer wrapping and empty sums. Float32 is computed in Float64, which can differ in edge cases.
  • Every benchmark answer is checked against Polars before it is timed.
Python

Python functions

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 →

Scope

Coverage

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 →

Installing the wheel

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")

FAQ

Do I have to rewrite anything?

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.

What happens when a query is not supported?

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.

Is it faster on everything?

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.

Which Polars version does it need?

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.

Is it production ready?

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.

How is it licensed?

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