-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating SArray with more that 14 entries uses allocation #384
Comments
This is the splatting penalty for StaticArrays.jl/src/convert.jl Line 3 in f7bf751
See e.g. JuliaLang/julia#22545, JuliaLang/julia#22370. Could work around the penalty in StaticArrays with an |
I'm just creating a large matrix with >14 entries. |
If possible, just pass a tuple: julia> @btime SVector{15}(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
13.507 ns (1 allocation: 128 bytes)
julia> @btime SVector{15}((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
3.701 ns (0 allocations: 0 bytes) |
Correct. In code, I recommend using tuples to construct static arrays. There's also a The non-tuple constructors are only mostly for convenience. They are nice for creating 3-vectors or playing at the REPL but actually don't make any sense w.r.t. all the Sorry @wsshin - since there's not much I can do about the splatting penalty from this side, I'll close this issue. |
Is this an expected behavior?
The text was updated successfully, but these errors were encountered: