Array slicing normally creates a copy. That is useful when the selected data should be independent, but repeatedly copying large slices inside a tight loop can hurt performance. @view creates a non-copying view: the selected elements remain connected to the original array. section 14.4 section 14.7
Share data without copying
julia> A = [8, 1, 2, 7] julia> B = @view A[3:end] 2-element view(::Vector{Int64}, 3:4) with eltype Int64: 2 7 julia> B[2] = 1331 1331 julia> A 4-element Vector{Int64}: 8 1 2 1331 Changing B changes the corresponding element of A because B refers to A's selected data. By contrast, B = A[:] produces an independent copy.
The same idea applies to multidimensional arrays. Use ordinary indexing to select rows, columns, or submatrices, then place @view before the slice when the result should reference the original matrix rather than copy its elements. section 14.4
