Utility functions

parfun.functions.parallel_map(func: Callable, *iterables, backend_session: BackendSession | None = None, timeout: float | None = None) Iterable

Similar to concurrent.futures.Executor.map() but lazily consumes and returns the iterators’ content as worker nodes get available.

parallel_map(math.sqrt, [4, 9, 16, 25])) # [2.0, 3.0, 4.0, 5.0]

parallel_map(int.__add__, [10, 7, 15], [12, 15, 5]) # [22, 22, 20]
Parameters:

backend_session – the parallel backend session. If None, creates a new session from the current backend.

parfun.functions.parallel_starmap(func: Callable, iterable: Iterable[Tuple[Any, ...]], backend_session: BackendSession | None = None, timeout: float | None = None) Iterable

Similar to concurrent.futures.Executor.starmap() but lazily consumes and returns the iterators’ content as worker nodes get available.

parallel_starmap(math.__add__, [(10, 12), (7, 15), (15, 5)]) # [22, 22, 20]
parfun.functions.parallel_timed_map(func: Callable, *iterables, backend_session: BackendSession | None = None, timeout: float | None = None) Iterable[Tuple[Any, int]]

Similar to parallel_map(), but returns the total execution time (including scheduling) of every sub task.

parallel_tiled_map(math.sqrt, [4, 9, 16, 25])) # [(2.0, 1234), (3.0, 3310), (4.0, 3132), (5.0, 4312)]
Parameters:

backend_session – the parallel backend session. If None, creates a new session from the current backend.