# Most performant way to get 0-d array pointing to a variable

**URL:** <https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947>\
**Category:** Performance\
**Created:** [March 16, 2019, 8:33pm UTC](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947 "2019-03-16T20:33:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndinsmore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndinsmore/32/7433_2.png) [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Post date:** [March 16, 2019, 8:33pm UTC](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947/1 "2019-03-16T20:33:05Z")

</div>

First this my be a little ill formatted as I am typing it on my phone at a muffler shop.

I am Trying to figure out what the most performance way of generating a 0-dim array of a variable to use as passing by ref.

Now for an array location it is relatively easy to use `view` to do just that. Which works great but ultimately must have some over head on access.

Then there is `unsafe_wrap` which in theory should have less access overhead than a sub array, but my benchmark says takes 3x as long to create. Plus my same benchmark says accessing it with say a += is not much fast than the view.

Using a `view` I guess would be okay untill you want to use it to pass the field of a mutable type.  
So is unsafe wrap the only way to do that?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 16, 2019, 8:35pm UTC](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947/2 "2019-03-16T20:35:18Z")

</div>

`Ref`

---

<div class="post-metadata">

**Author:** ![ndinsmore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndinsmore/32/7433_2.png) [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Post date:** [March 16, 2019, 8:50pm UTC](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947/3 "2019-03-16T20:50:46Z")

</div>

Thank you I don’t know how I missed that.
