You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that when we see fun1(fun2(x)) the function passed to transform should be fun1 \circ fun2. That way we can take advantage of more fast paths iirc.
The text was updated successfully, but these errors were encountered:
Yes and the thing is that fun1 \circ fun2 is compiled only once as opposed to x -> fun1(fun2(x)) which has to be compiled every time. but I would label it as a minor improvement.
Actually I had implemented something like that back in 2019 before you cleaned up the package. FWIW, here are the functions I had written:
"""Check whether expression is a single-argument call, like f(x)"""isoneargcall(e::Expr) =
e.head ===:call&&length(e.args) ==2&& e.args[1] isa Symbol
functiontocomposition(body)
if body.head == :(=) &&length(body.args) ==2&&
body.args[2] isa Expr
funs = Symbol[]
e = body.args[2]
while e isa Expr &&isoneargcall(e)
push!(funs, e.args[1])
e = e.args[2]
endif e isa Symbol || (e isa QuoteNode && e.value isa Symbol)
# Recursion parsed the full expressionreturnmapreduce(eval, ∘, funs)
else# Expression doesn't consist only in single-argument callsreturn body
endendreturn body
end
I think that when we see
fun1(fun2(x))
the function passed totransform
should befun1 \circ fun2
. That way we can take advantage of more fast paths iirc.The text was updated successfully, but these errors were encountered: