Adding a Par construct to Python?
Diez B. Roggisch
deets at nospam.web.de
Sun May 17 14:36:36 EDT 2009
> 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
More information about the Python-list
mailing list