Hi,
Here are 2 functions g1, g2 that return its Int64 argument as-is. What is important, both of them are identical w.r.t. code_(typed|lowered|llvm|native)\(g(1|2), \(Int64,\)\). The only difference is - as you see - that the second one is the result of calling some method.
function g1(x::Int64)
x
end
function generate_g2()
function g2(x::Int64)
x # substituting x for x::Int64 does not change anything
end
end
g2 = generate_g2()
It seems that there are problems with auto guessing retval types, for example:
3-element Array{Int64,1}: ### Int64 - OK
1
2
3
3-element Array{Any,1}: ### Any :(
1
2
3
This of course has a huge impact for the performance of certain ops, like:
@time [g1(i) for i in 1:1000000]
elapsed time: 0.004126231 seconds (8000048 bytes allocated)
@time [g2(i) for i in 1:1000000]
elapsed time: 0.393538948 seconds (71967360 bytes allocated)
Should I post this as an issue on GitHub?
The result were obtained on Julia version 0.3.0-prerelease+1805 (2014-03-01 23:11 UTC) Commit a5b5d64* (0 days old master, fetched 10 mins ago).
Best regards,
Marek