-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
If I have an array of immutable datastructures, it would be extremely advantageous from a performance perspective to be able to mutate that array in place instead of replacing it. The @set and @set! macros don't currently support this.
julia> using Setfield
julia> x = [(a=rand(), b=rand()) for _=1:2]
2-element Array{NamedTuple{(:a, :b),Tuple{Float64,Float64}},1}:
(a = 0.13871066644823227, b = 0.12386194648118187)
(a = 0.46679798730440436, b = 0.6032333077678709)
julia> y = x;
julia> @set! x[1].a = 0.0
2-element Array{NamedTuple{(:a, :b),Tuple{Float64,Float64}},1}:
(a = 0.0, b = 0.12386194648118187)
(a = 0.46679798730440436, b = 0.6032333077678709)
julia> y
2-element Array{NamedTuple{(:a, :b),Tuple{Float64,Float64}},1}:
(a = 0.13871066644823227, b = 0.12386194648118187)
(a = 0.46679798730440436, b = 0.6032333077678709)Any ideas on supporting this use-case?
EDIT: possible duplicate of #32
EDIT2: and possibly solved by the macro definitions in the examples folder? Is there a reason those are an example rather than an exported part of Setfield.jl's public api?
drelatgithub
Metadata
Metadata
Assignees
Labels
No labels