3 ms·
Do you wanna say a few more words about this? I thought that `v[1:10]` always causes allocation but `view(v, 1:10)` never does. Is this not the case, or has thi
by doublesCs 6y ago
Do you wanna say a few more words about this? I thought that `v[1:10]` always causes allocation but `view(v, 1:10)` never does. Is this not the case, or has this changed?
- mfsch 6y ago`view(v, 1:N)` did cause an allocation in previous versions, but the allocation was a small, fixed size while `v[1:N]` would allocate memory proportional to `N`. From what I understand, this was required to avoid garbage collection of `v` in cases where the view would be the only remaining reference to that array. In 1.5, changes to the GC allow views to be placed on the stack now.