'How to use parallel processing filter in Python?
I know that in Python, map is equivalent to parallel processing class of pool.map from multiprocessing module.
Is there a filter equivalent in parallel programming for Python?
Solution 1:[1]
Python has most of function orientated programming paradigms that are necessary. Such as map, filter and reduce which you can find here
That being said, multiprocessing doesn't support filter because lambdas are not pickleable by default.
But you can always implement your own using functions mentioned above or reproducing them in manner that suits you using iterators, generators or list comprehension.
One of examples taken from sagemath is:
def pool_filter(pool, func, candidates):
return [c for c, keep in zip(candidates, pool.map(func, candidates)) if keep]
But it further depends on your implementation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
