jump-dev / MutableArithmetics.jl

Interface for arithmetics on mutable types in Julia
Mozilla Public License 2.0
49 stars 8 forks source link

operate_fallback!! shouldn't force the first argument to be copied #287

Open blegat opened 4 months ago

blegat commented 4 months ago

In this redirection: https://github.com/jump-dev/MutableArithmetics.jl/blob/7344c9468072bd663feec7e4cdc1a0e98e34ea19/src/interface.jl#L592-L599 We redirect to operate because for instance, when it's used in the @rewrite macro, we want to modify the result so it cannot depend on the the arguments. However, since the first argument was given to operate!!, it can actually be modified! So in this case, we want a result that does not depend on any argument except the first one. This can causes performance issues in https://github.com/JuliaAlgebra/StarAlgebras.jl/pull/21/files#diff-3f191d1ba6c7bc538c1bf193064434a4984a0457baac3da62c9e6dede5d566aa for canonical as reported by @kalmarek