Skip to main content

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)

Uploaded Source

Built Distribution

run_parallel-0.0.6-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page