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.5.tar.gz
(8.0 kB
view hashes)
Built Distribution
Close
Hashes for run_parallel-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f73b0a5bdacd06677f17355662bbc2700d7f410c830e742670fb552a7d7cd9d5 |
|
MD5 | 972eadcaf87808c9d7a0f1268d184eb4 |
|
BLAKE2b-256 | 3e64ef0f75be1aa189b2475426aa774db614197aa63e68837b302d1a3afa4ea0 |