brainevent.config.set_numba_parallel

brainevent.config.set_numba_parallel#

brainevent.config.set_numba_parallel(parallel=True, num_threads=None)[source]#

Enable or disable Numba parallel execution and optionally set the thread count.

Controls whether Numba-based kernels in brainevent use parallel execution (via numba.prange). When num_threads is provided, it also calls numba.set_num_threads to configure the Numba thread pool size.

Parameters:
  • parallel (bool) – If True, enable Numba parallel mode. If False, disable it. Defaults to True.

  • num_threads (int | None) – Number of threads for Numba’s thread pool. If None, the Numba default is used (typically the number of CPU cores). Defaults to None.

See also

get_numba_parallel

Query whether Numba parallel mode is enabled.

get_numba_num_threads

Query the configured Numba thread count.

Notes

Setting num_threads imports the numba package and immediately calls numba.set_num_threads. This affects all subsequent Numba JIT-compiled functions, not just those in brainevent.

Kernels read the flag when they are compiled, and JAX caches compiled executables independently of it. If this call changes the flag it therefore calls jax.clear_caches(), so already-compiled call sites recompile with the new setting on their next use. Like set_backend(), it is a setup-time, single-threaded control.

Examples

>>> import brainevent
>>> brainevent.config.set_numba_parallel(True, num_threads=4)
>>> brainevent.config.get_numba_parallel()
True
>>> brainevent.config.get_numba_num_threads()
4