merton.batch.dispatch

Parallel-dispatch helpers shared by panel-fitting entry points.

The default is joblib (prefer="threads") because our hot path releases the GIL inside the Numba kernels — threading scales well without the overhead of process pools. For users who already have a Dask or Ray cluster, the same panel API accepts dispatch="dask" / "ray" and falls back to lazy imports.

Functions

parallel_map(→ list[R])

Apply fn to every element of items in parallel.

Module Contents

merton.batch.dispatch.parallel_map(fn: collections.abc.Callable[[T], R], items: collections.abc.Sequence[T], *, dispatch: str = 'joblib', n_jobs: int = -1, progress: bool = False, description: str = 'merton') list[R][source]

Apply fn to every element of items in parallel.

Parameters:
  • dispatch"joblib" (default, threads) | "sequential" | "dask" | "ray". Dask / Ray require the corresponding library to be installed; we lazy-import on first use.

  • n_jobs – Number of parallel workers. -1 means all logical cores.

  • progress – Show a rich.progress bar for the dispatch.

  • description – Label shown alongside the progress bar.