4 ms·
>Consider `[]struct{nested []struct{i int}}`. A typical example, yeah. I've said about structs of ints already, it's not a common type unfortunately anywhere b
by ernst_klim 8y ago
>Consider `[]struct{nested []struct{i int}}`.
A typical example, yeah. I've said about structs of ints already, it's not a common type unfortunately anywhere beyond number crunching, in which go sucks anyway.
In haskell you could have unboxed array with unboxed records. Check Vector.Unboxed.
- weberc2 8y ago> I've said about structs of ints already Yeah, but you were wrong (you said other kinds of structs would escape to the heap). The innermost struct could have a string member and a `*HeapData` member; it wouldn't matter. The difference in number of allocations between Go and others would remain the same. The difference isn't driven by the leaves, it's driven by number of nodes in the object graph; the deeper or wider the tree, the better Go performs relative to other GC languages. > In haskell you could have unboxed array with unboxed records. Check Vector.Unboxed. For sure, but in Go "unboxed" is the default (i.e., common, idiomatic); in Haskell it's an optimization.