Skip to content

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

Open
@blegat

Description

@blegat

In this redirection:

function operate_to_fallback!!(
::IsNotMutable,
output,
op::F,
args::Vararg{Any,N},
) where {F<:Function,N}
return operate(op, args...)
end

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions