# @distributed (op) for with mutable types

**URL:** https://discourse.julialang.org/t/distributed-op-for-with-mutable-types/38845
**Category:** New to Julia
**Tags:** distributed, loops
**Created:** [May 5, 2020, 11:12pm UTC](https://discourse.julialang.org/t/distributed-op-for-with-mutable-types/38845 "2020-05-05T23:12:56Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [May 6, 2020, 10:37pm UTC](https://discourse.julialang.org/t/distributed-op-for-with-mutable-types/38845/8 "2020-05-06T22:37:54Z")

</div>

> [@Marco\_Lombardi](#):
>
> Yes, but I think `mapreduce` is not distributed, is it?

You are right. `mapreduce` in `Base` has no parallelism. Perhaps Distributed.jl should add it. (You can also use `Transducers.dreduce(op, Map(f), itr)`)

> [@Marco\_Lombardi](#):
>
> Also, from the Julia documentation I read that `pmap` (and therefore I guess also a parallel version of `mapreduce` ) should be used in situation where the function is slow to compute, while `@distributed for` is more appropriate for quick computation.

This is not generally true. Functional approach can have much better performance characteristics (see, e.g., [[RFC/ANN] FLoops.jl: fast generic for loops (foldl for humans™)](https://discourse.julialang.org/t/37876)).

> [@Marco\_Lombardi](#):
>
> I think that a simple change would make it return also the index `i` of the maximum, on top of the maximum value.

You need two accumulators to interact to get this. So, you can’t just independently annotate each reduction variable.

---

_[View the full topic](https://discourse.julialang.org/t/distributed-op-for-with-mutable-types/38845)._
