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.4.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for run_parallel-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d4dc3e3a47e986671f3ed128919d52af8a55e40dad78f96bac5972bdf4ccb56 |
|
MD5 | 9faf4c9204ed78b9d96b1e90b55570af |
|
BLAKE2b-256 | 75001841eb4c73ee5de56da77c6e1998a5252a682167d6add7d9ae2fa6a6b46b |