Parallel execution¶
-
unified_map.univariate.parallel.
dask
(function, argument_list, num_cores=None)¶ Apply a univariate function to a list of arguments in a parallel fashion.
Uses Dask’s delayed() function to build a task graph and compute() function to calculate results.
Parameters: - function – A callable object that accepts one argument
- argument_list – An iterable object of input arguments
- num_cores (optional) – Number of cores to use for calculation.
Returns: List of output results
Example
>>> def square(x): ... return x**2 ... >>> dask(square, [1, 2, 3, 4, 5]) [1, 4, 9, 16, 25]
References
-
unified_map.univariate.parallel.
futures
(function, argument_list, num_cores=None)¶ Apply a univariate function to a list of arguments in a parallel fashion.
Uses Python’s built-in futures with a process pool executor.
Parameters: - function – A callable object that accepts one argument
- argument_list – An iterable object of input arguments
- num_cores (optional) – Number of cores to use for calculation.
Returns: List of output results
Example
>>> def square(x): ... return x**2 ... >>> futures(square, [1, 2, 3, 4, 5]) [1, 4, 9, 16, 25]
References
-
unified_map.univariate.parallel.
joblib
(function, argument_list, num_cores=None)¶ Apply a univariate function to a list of arguments in a parallel fashion.
Uses Joblib’s delayed() function with a parallel executor that starts multiple processes.
Parameters: - function – A callable object that accepts one argument
- argument_list – An iterable object of input arguments
- num_cores (optional) – Number of cores to use for calculation.
Returns: List of output results
Example
>>> def square(x): ... return x**2 ... >>> joblib(square, [1, 2, 3, 4, 5]) [1, 4, 9, 16, 25]
References
-
unified_map.univariate.parallel.
multiprocessing
(function, argument_list, num_cores=None)¶ Apply a univariate function to a list of arguments in a parallel fashion.
Uses the parallel map() function with a pool of processes from multiprocessing in Python’s standard library.
Parameters: - function – A callable object that accepts one argument
- argument_list – An iterable object of input arguments
- num_cores (optional) – Number of cores to use for calculation.
Returns: List of output results
Example
>>> def square(x): ... return x**2 ... >>> multiprocessing(square, [1, 2, 3, 4, 5]) [1, 4, 9, 16, 25]
References