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.3.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for run_parallel-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a190f0367160cc953d928a7820eb8a29d2469b346a3717a9679bb604594a8203 |
|
MD5 | 2c0571a351499c2e07584abb178e88f5 |
|
BLAKE2b-256 | 3fb92d1ccc0bb8cfaaa9aa9688e3519445d1c979732ea9b764289d1aa10d44e3 |