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.2.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for run_parallel-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b834cec1df541d6fd13258b845fc9a4a4df8c0070910d5e0d1828330764848bf |
|
MD5 | fe48a63a553875105474230e2c443f0f |
|
BLAKE2b-256 | 3fa50fffb3b9c4370ac8cf6bdbfeb5a7bddfacc16b838193113cb1b93a562593 |