# Parsimonious way to unpack big structs

**URL:** <https://discourse.julialang.org/t/parsimonious-way-to-unpack-big-structs/66522>\
**Category:** General Usage\
**Tags:** struct\
**Created:** [August 17, 2021, 12:02am UTC](https://discourse.julialang.org/t/parsimonious-way-to-unpack-big-structs/66522 "2021-08-17T00:02:34Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![bertschi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bertschi/32/33462_2.png) [@bertschi](https://discourse.julialang.org/u/bertschi)\
**Post date:** [January 28, 2024, 11:39am UTC](https://discourse.julialang.org/t/parsimonious-way-to-unpack-big-structs/66522/19 "2024-01-28T11:39:51Z")

</div>

No, `@unpack` is a macro and expands essentially to the same code. Have checked for `SimpleUnPack.@unpack` and `Parameters.@unpack` and all of these functions reduce to the same code, i.e., at the level of `@code_typed`:

```julia
function unpack_1(p)
    Parameters.@unpack α, β, γ = p
    α + β + γ
end
function unpack_2(p)
    SimpleUnPack.@unpack α, β, γ = p
    α + β + γ
end
function unpack_3(p)
    α, β, γ = p.α, p.β, p.γ
    α + β + γ
end

```

In any case, you can always check fo yourself:

```julia-repl
julia> @code_typed unpack_1(p)
CodeInfo(
1 ─ %1 = Base.getfield(p, :α)::Any
│ %2 = Base.getfield(p, :β)::Any
│ %3 = Base.getfield(p, :γ)::Any
│ %4 = (%1 + %2 + %3)::Any
└── return %4
) => Any

julia> @macroexpand SimpleUnPack.@unpack α, β, γ = p
:((; α, β, γ) = p)

```

---

_[View the full topic](https://discourse.julialang.org/t/parsimonious-way-to-unpack-big-structs/66522)._
