# SVectors + @reset from Accessors: Strange Benchmarks

**URL:** <https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201>\
**Category:** General Usage\
**Tags:** benchmarktools, staticarrays, setfield, accessors\
**Created:** [September 9, 2024, 2:50am UTC](https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201 "2024-09-09T02:50:02Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Tetrakai](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Post date:** [September 9, 2024, 3:17pm UTC](https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201/5 "2024-09-09T15:17:01Z")

</div>

I agree, something more is going on. I found this from a couple years ago which probably explains it:

> 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).  
> [Container of mutable structs without 100x slowdown? - #5 by ffevotte](https://discourse.julialang.org/t/container-of-mutable-structs-without-100x-slowdown/86629/5)

It looks like a proposed fix was rejected?

> <https://github.com/JuliaObjects/Accessors.jl/pull/55>
>
> The main common usecase is using \`@(re)set\` with an array element, as in \`@set $…(x\[i\]).a.b = 123\` and \`@reset $(x\[i\]).a.b = 123\`.
> Currently, these require a temporary variable:
> \`\`\`
> old = x\[i\]
> new = @set old.a.b = 123
> \`\`\`
> and
> \`\`\`
> old = x\[i\]
> x\[i\] = @set old.a.b = 123
> \`\`\`

---

_[View the full topic](https://discourse.julialang.org/t/svectors-reset-from-accessors-strange-benchmarks/119201)._
