Well, that makes sense. However, if I wrap the code in a function, I think I should be free of that extra allocation but it still remains.
function main()
T = Float64
f(x) = x[1] * x[2]
wrapf = FunctionWrapper{T,Tuple{Tuple{T,T}}}(f)
p = (1.0, 2.0)
x = wrapf(p)
return nothing
end
@btime main()
I have also tried with some of the examples in FunctionWrappers.jlβs tests and they have the same allocation behaviour. It seems there are always allocations when the wrapper is created.
Since T is defined in the body as a constant value I donβt think that applies here. Looking at @code_llvm it seems to know to define doubles in either case.
Thank you all for your i put. I think yhese are allocations to live with.
I took a look at some SciML code where these wrappers are used and got to the conclusion that they are used of, say, a ODEProblem, and one just pays the allocation cost once.