You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Taking a view intends to minimize allocation. However, for some lazy arrays, allocating a concrete subarray could be more efficient. The proposal is as follows
maybeview(A::AbstractArray, args...) =maybeview(MemoryLayout(A), A, args...)
maybeview(::MemoryLayout, A, args...) =view(A, args...)
maybeview(::AbstractLazyLayout, A, args...) = A[args...] # at LazyArrays.jl
The text was updated successfully, but these errors were encountered:
# maybeview is like getindex, but returns a view for slicing operations
# (while remaining equivalent to getindex for scalar indices and non-array types)
So your proposal would be inconsistent with the definition. But we could call it something else.
Btw I've started not using the same function name with extra arguments (following some good changes from @jishnub) so I would call this:
maybeview(A::AbstractArray, args...) =maybeview_layout(MemoryLayout(A), A, args...)
maybeview_layout(::MemoryLayout, A, args...) =view(A, args...)
maybeview_layout(::AbstractLazyLayout, A, args...) = A[args...] # at LazyArrays.jl
motivation is from #153
Taking a view intends to minimize allocation. However, for some lazy arrays, allocating a concrete subarray could be more efficient. The proposal is as follows
The text was updated successfully, but these errors were encountered: