But reduce() can't tell whether the function being applied is commutative or not. I suppose it could special-case a handful of special cases (e.g. operator.add for int arguments -- but not floats!) or take a caller- supplied argument that tells it whether the function is commutative or not. But in general, you can't assume the function being applied is commutative or associative, so unless you're willing to accept undefined behaviour, I don't see any practical way of parallelizing reduce().

def reduce(operation, sequence, startitem=None, parallelize=False)

should be enough. Approaches such as OpenMP also don't guess, they use explicit annotations.

Diez
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to