core

Utility functions for parallel operations.

source

parallel

 parallel (func, arr:Collection, max_workers:int=None, leave=False,
           use_threads=True)

Execute the function in parallel on the elements of the input collection.

Returns: results (list): A list of the results of the function execution

Type Default Details
func The function to be executed
arr typing.Collection The input collection
max_workers int None The maximum number of workers to use
leave bool False Whether to leave the progress bar after completion
use_threads bool True Whether to use threads or processes as workers
test_array = list(range(10))
test_array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_func(index, array):
    array[index]*=2
partial_func = partial(test_func, array=test_array)
parallel(partial_func, arr=range(len(test_array)), leave=True)
test_array
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]