# Container of mutable structs without 100x slowdown?

**URL:** <https://discourse.julialang.org/t/container-of-mutable-structs-without-100x-slowdown/86629>\
**Category:** Performance\
**Tags:** struct, accessors\
**Created:** [September 1, 2022, 8:00am UTC](https://discourse.julialang.org/t/container-of-mutable-structs-without-100x-slowdown/86629 "2022-09-01T08:00:55Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [September 1, 2022, 10:54am UTC](https://discourse.julialang.org/t/container-of-mutable-structs-without-100x-slowdown/86629/5 "2022-09-01T10:54:14Z")

</div>

> [@lmiq](#):
>
> There is `Setfield.jl` which has a simpler syntax, apparently: `@set! s.x = 1 `

Yes, `Accessors.jl` is actually the successor of `SetField.jl` (but the latter is still maintained).

_(I’m not a very proficient user of `SetField` / `Accessors`, so take the following with a grain of salt)_

`Accessors.jl` also provides the nice syntax `@set s.x = 1`, but I don’t think it works when `s` is replaced by something like `a[i]`.

In other words, I think `@set a[i].s = 1` is interpreted as : “give me a copy of `a` in which the `x` field of the `i`-th element is set to 1”. As opposed to “give me a copy of `a[i]` in which the `x` field is set to 1” (which would be the desired semantics here).

---

_[View the full topic](https://discourse.julialang.org/t/container-of-mutable-structs-without-100x-slowdown/86629)._
