Pass an array or generator of callables and `run_parallel` will run them as fast as possible.
Project description
run_parallel
Pass an array or generator of callables and run_parallel
will run them as fast as possible.
Lambdas are not supported yet.
Example
As computations are often a little bit complex, classes make
sense often. Override the __call__
method:
class ExensiveComputation:
def __init__(self, arg):
self.arg = arg
def __call__(self):
res = self._step1(self.arg)
res = self._step2(res)
return res
def _step1(self, arg):
# expensive stuff here
return res
def _step2(self, arg):
# expensive stuff here
return res
computations = [ExensiveComputation(1), ExensiveComputation(2), ExensiveComputation(3)]
res1, res2, res3 = run_parallel(computations)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
run_parallel-0.0.6.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for run_parallel-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2d266c0269fac3fc402f72981ee1eaf18d6c86535d30d515e052cc8db2b63a0 |
|
MD5 | 948019fea758e8c0c90cdeedb9c0ed4a |
|
BLAKE2b-256 | b2ffd3ea03c11d775056358b7127732baa20eb0fcd4a6e70d261c4649e7be74b |