# How does Julia store array sizes?

**URL:** <https://discourse.julialang.org/t/how-does-julia-store-array-sizes/56226>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 1, 2021, 3:43am UTC](https://discourse.julialang.org/t/how-does-julia-store-array-sizes/56226 "2021-03-01T03:43:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nchisholm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nchisholm/32/37414_2.png) [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Post date:** [March 1, 2021, 3:43am UTC](https://discourse.julialang.org/t/how-does-julia-store-array-sizes/56226/1 "2021-03-01T03:43:19Z")

</div>

Very simple question, but to my surprise I was unable to find an answer by Googling / searching this forum.

Where/how does Julia internally store size/shape/length information for arrays? I know you just use the `size` function to get the size of each dimension, but what does this function actually do? I was thinking Arrays might be implemented internally as an (immutable) struct with a buffer containing the raw data, a `size` field (tuple), and possibly other information. Of course, Arrays are not structs and have no fields. (Perhaps they are internally but this is hidden from view?)

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [March 1, 2021, 3:59am UTC](https://discourse.julialang.org/t/how-does-julia-store-array-sizes/56226/2 "2021-03-01T03:59:49Z")

</div>

First of all, welcome to our community! 🎊

I think Julia arrays are implemented in C, not Julia, so they are not structs. As how they implement size, this is an implementation detail, you probably should look at the sources: [`size`](https://github.com/JuliaLang/julia/blob/045d10e371c222000d4386240694f71a89383f8e/base/array.jl#L132) calls [`arraysize`](https://github.com/JuliaLang/julia/blob/b39d697a370ecfb61fb57074ef908d20529473b9/src/builtins.c#L1163) that seems to be a C function.

---

<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:** [March 1, 2021, 4:12am UTC](https://discourse.julialang.org/t/how-does-julia-store-array-sizes/56226/3 "2021-03-01T04:12:37Z")

</div>

> [@nchisholm](#):
>
> I was thinking Arrays might be implemented internally as an (immutable) struct with a buffer containing the raw data, a `size` field (tuple), and possibly other information. Of course, Arrays are not structs and have no fields.

Yes, this is the [`jl_array_t` type defined in C](https://github.com/JuliaLang/julia/blob/e784dd010ab1052e4e777676e95b47405519b179/src/julia.h#L189-L208).

---

<div class="post-metadata">

**Author:** ![nchisholm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nchisholm/32/37414_2.png) [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Post date:** [March 1, 2021, 3:36pm UTC](https://discourse.julialang.org/t/how-does-julia-store-array-sizes/56226/4 "2021-03-01T15:36:47Z")

</div>

Thanks for your explanation pointing out the call to C. I tried looking at the source before, but I could not quite make sense of it due to inexperience with Julia.
