Iterator yielding tuples vs arrays

An alternative is to use the existing StaticArrays.jl package to wrap the tuples. A StaticArray is just a Tuple wrapped to behave like an array. It incurs no heap allocations in most situations.

julia> using StaticArrays

julia> Iterators.map(SVector, P) |> collect # remove the collect in actual use
2×2×2 Array{SVector{3, Int64}, 3}:
[:, :, 1] =
 [1, 1, 1]   [1, -1, 1]
 [-1, 1, 1]  [-1, -1, 1]

[:, :, 2] =
 [1, 1, -1]   [1, -1, -1]
 [-1, 1, -1]  [-1, -1, -1]
2 Likes