Apply a function to every element of a list, in separate threads
Interface is similar to multiprocessing.map, except it runs in threads
Parameters: | target : callable
iterable : iterable
args : sequence
thread_count : integer
kwargs : dict
|
---|---|
Returns: | out : list
|
Examples
find totals of several arrays
>>> import numpy
>>> from spacepy import toolbox
>>> inputs = range(100)
>>> totals = toolbox.thread_map(numpy.sum, inputs)
>>> print(totals[0], totals[50], totals[99])
(0, 50, 99)