# Performance costs associated with using local variable bindings

**URL:** <https://discourse.julialang.org/t/performance-costs-associated-with-using-local-variable-bindings/99465>\
**Category:** Performance\
**Created:** [May 26, 2023, 9:29pm UTC](https://discourse.julialang.org/t/performance-costs-associated-with-using-local-variable-bindings/99465 "2023-05-26T21:29:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![qua4tre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qua4tre/32/47504_2.png) [@qua4tre](https://discourse.julialang.org/u/qua4tre)\
**Post date:** [May 26, 2023, 9:29pm UTC](https://discourse.julialang.org/t/performance-costs-associated-with-using-local-variable-bindings/99465/1 "2023-05-26T21:29:52Z")

</div>

Is there any impact on performance of a function from using local variable bindings for convenience and readability? For example,

```julia
function foo(x)
    a,b = x[1:2]
    return a^2 + b^2
end

```

vs

```julia
function bar(x)
    return x[1]^2 + x[2]^2
end

```

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [May 26, 2023, 9:35pm UTC](https://discourse.julialang.org/t/performance-costs-associated-with-using-local-variable-bindings/99465/2 "2023-05-26T21:35:53Z")

</div>

no, but slicing copies so you should use a view.
