Kwker

Quickstart: NumPy

Make the sorting calls in a NumPy program faster without changing them. After one line, np.sort, np.argsort, np.partition, np.unique, np.searchsorted and the set operations run on Kwker, and return what NumPy would. About five minutes.

Install

ShellOn your machine.
pip install kwker
python -m kwker doctor            # your CPU, the engine Kwker picked, any warnings

Switch it on

PythonRuns on your machine.
import numpy as np
import kwker.numpy_ops

kwker.numpy_ops.install()            # from here on, np.sort and the others run Kwker
x = np.random.default_rng(0).integers(0, 1000, 1_000_000)
print(np.sort(x)[:5])
Output
[0 0 0 0 0]

Call it once at the start of your program. kwker.numpy_ops.uninstall() switches it off again.

Check the results

The results are NumPy's own. To see it on your data, compare inside and outside an accelerated() block:

PythonRuns on your machine.
import numpy as np
import kwker.numpy_ops

x = np.random.default_rng(1).standard_normal(500_000)
with kwker.numpy_ops.accelerated():   # Kwker inside the block only
    fast = np.argsort(x, kind="stable")
print(np.array_equal(fast, np.argsort(x, kind="stable")))
Output
True

Measure it on your machine

ShellOn your machine.
python -m kwker.bench --quick       # sorting and selection vs NumPy, PyTorch, pyarrow and Polars

Next steps