# Sum over tuple slower than sum over array

**URL:** <https://discourse.julialang.org/t/sum-over-tuple-slower-than-sum-over-array/125162>\
**Category:** Performance\
**Created:** [January 24, 2025, 12:02pm UTC](https://discourse.julialang.org/t/sum-over-tuple-slower-than-sum-over-array/125162 "2025-01-24T12:02:01Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 24, 2025, 12:34pm UTC](https://discourse.julialang.org/t/sum-over-tuple-slower-than-sum-over-array/125162/4 "2025-01-24T12:34:18Z")

</div>

> [@miguelborrero](#):
>
> I see! I saw tuples as static-size arrays given that (aside from the type name) they have a type label and also a size label and therefore I thought that whenever possible making use of this static property by letting the compiler take it for granted would be weakly better. However, my intuition seems to naive! Thanks a lot for the reply.

StaticArrays.jl use tuples under the hood, and you should also use them only for small arrays. Static-size arrays _don’t_ help the compiler when the length is large, and can easily hurt — it’s like you’re trying to compile code that has 10^7 local variables. See, for example:

- [What's the deal with StaticArrays? - #2 by stevengj](https://discourse.julialang.org/t/whats-the-deal-with-staticarrays/115816/2)

---

_[View the full topic](https://discourse.julialang.org/t/sum-over-tuple-slower-than-sum-over-array/125162)._
