Would there be major benefits to be had? I imagine array dimensions would move into Julia’s type system—would this be valuable for dispatch or bounds checking?
faster empty array construction. Right now Constructing a Float64[] takes about 20ns and it should take more like 6ns (the difference is because we aren’t able to constant propagate some of the information across the language barrier).
The implementation would involve adding a C type for a fixed sized mutable buffer which would be a better thing to use for lists that we use in other data-structures (e.g. Dict) that currently have some memory overhead as a result of the multi-conditionality and resizing that Arrays support.
This seems like something that could have been mildly more ergonomic if BaseArrays were implemented in Julia (docstring for StaticArrays.jl SMatrix):
SMatrix{S1, S2}(mat::Matrix)
Construct a statically-sized matrix of dimensions S1 × S2 using the data from mat. The parameters S1 and S2 are
mandatory since the size of mat is unknown to the compiler (the element type may optionally also be specified).
No, the distinction between arrays with a runtime size (e.g. the built-in Array type) and a static/compile-time size (StaticArrays) is a semantic choice that has nothing to do with whether it is implemented in pure Julia. We don’t wantArray to have a static size (part of the type), because that severely limits what you can do with it. StaticArrays are great but are much more specialized.
Thanks, I see. I had given myself the impression that, as multidimensional arrays’ size is immutable, it might be something that’d be desirable to track in the type system or dispatch on. But I am a dilettante here.
It is stored in the type system, but we also store it in the datatype (because it is faster to get that way and the sizes work out to make it basically free).