-
Notifications
You must be signed in to change notification settings - Fork 44
Adding support for components/broadcasting/views with StructArrays of StaticArrays #186
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
Conversation
Thank you for the PR! It mostly looks good, I've added a few nitpicking in the comments. |
Co-authored-by: Pietro Vertechi <[email protected]>
Co-authored-by: Pietro Vertechi <[email protected]>
Co-authored-by: Pietro Vertechi <[email protected]>
enables non-allocating views for StaticArray types
added Improves performance for tuples julia> x = StructArray((rand(2,2),rand(2,2)));
julia> function Base.view(s::StructArray{T, N, C}, I...) where {T, N, C}
StructArray{T}(map(v -> view(v, I...), StructArrays.components(s)))
end
julia> @btime view($x,$:,$1);
935.464 ns (11 allocations: 416 bytes)
julia> @inline function Base.view(s::StructArray{T, N, C}, I...) where {T, N, C}
StructArray{T}(map(v -> view(v, I...), StructArrays.components(s)))
end
julia> @btime view($x,$:,$1);
3.906 ns (0 allocations: 0 bytes) Improves performance for StaticArrays julia> x = StructArray(SVector{2}.(rand(2,2), rand(2,2)));
julia> function Base.view(s::StructArray{T, N, C}, I...) where {T, N, C}
StructArray{T}(map(v -> view(v, I...), StructArrays.components(s)))
end
julia> @btime view($x,$:,$1);
932.808 ns (11 allocations: 416 bytes)
julia> @inline function Base.view(s::StructArray{T, N, C}, I...) where {T, N, C}
StructArray{T}(map(v -> view(v, I...), StructArrays.components(s)))
end
julia> @btime view($x,$:,$1);
4.092 ns (0 allocations: 0 bytes) Doesn't seem to really impact NamedTuples. julia> x = StructArray((a=rand(2,2),b=rand(2,2)));
julia> function Base.view(s::StructArray{T, N, C}, I...) where {T, N, C}
StructArray{T}(map(v -> view(v, I...), StructArrays.components(s)))
end
julia> @btime view($x,$:,$1);
201.029 ns (5 allocations: 304 bytes)
julia> @inline function Base.view(s::StructArray{T, N, C}, I...) where {T, N, C}
StructArray{T}(map(v -> view(v, I...), StructArrays.components(s)))
end
julia> @btime view($x,$:,$1);
200.084 ns (5 allocations: 304 bytes) |
LGTM! I've suggested some minor changes of wording and formatting. If you are happy with those, you can just accept the changes and this should be good to go. I will just wait a little bit before merging because it is a breaking change, so that gives a chance to people relying on the old behavior to look at it. |
Co-authored-by: Pietro Vertechi <[email protected]>
Co-authored-by: Pietro Vertechi <[email protected]>
Co-authored-by: Pietro Vertechi <[email protected]>
Sounds great. Thanks for the guidance throughout this PR! |
provides StructArrays of SVectors until JuliaArrays/StructArrays.jl#186 is merged
Thanks again for the very nice contribution! |
Thank you for taking the time to review my code and walk me through my first PR! |
@piever do have a timeline for releasing a new version with this PR? We're using the StaticArrays functionality in https://github.com/trixi-framework/Trixi.jl/, but the CI is somewhat involved and is having issues with |
I was hoping to clump more breaking changes (from https://github.com/JuliaArrays/StructArrays.jl/milestone/2) with this one, but I clearly don't have the bandwidth to work on those at the moment. Even though this is the only breaking change, I guess it is not too bad to just tag 0.6 now (the updating should be almost automated for most dependent packages). |
No pressure either way - we can work on the CI on our end too. However, a 0.6 tag would certainly be nice for our CI setup :) |
In the end, it's probably best to tag now to see if overall users are happy with the new StaticArrays support. I'll just wait a little bit to see if there is an easy solution to JuliaData/WeakRefStrings.jl#72 (to keep supporting julia 1.0), otherwise I'll just require julia 1.3 and tag. |
@jlchan the 0.6 tag was just merged in the General Registry. |
Thank you! Much appreciated. |
Enables both StructArrays.components and broadcasting with StaticArray types. Fixes #179.