3 ms·
I'm very happy that using views no longer forces allocations. I like that I can choose both performant _and_ safe, rather than being forced to make a choice. K
by techwizrd 6y ago
I'm very happy that using views no longer forces allocations. I like that I can choose both performant _and_ safe, rather than being forced to make a choice.
Kudos to everyone who contributed to yet another great release!
- mfsch 6y agoStack-allocated views are a big deal! Even in code where the direct cost of the view allocations is acceptable (e.g. because the work per view is high), they should help a lot. Unnecessary allocations are one of the easiest way to accidentally mess up performance in Julia, but having all the views allocated made it much harder to find “problematic” allocations that scale with the problem size. Now it should be more realistic to aim for zero allocations in performance-critical code without giving up the nice ergonomics of views.
- doublesCs 6y agoDo 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.