如何判断为方法编译了哪些特化?

col*_*ang 8 julia

性能提示中,它说f(x::Int...) = tuple(x...)不会专门化。它还建议用于(@which f(...)).specializations检查专业化。

f(x::Int...) = tuple(x...)

f(1)
f(1, 2)
f(1, 2, 3)
f(1, 2, 3, 4)

a = first(methods(f)).specializations

Core.TypeMapEntry(Core.TypeMapEntry(nothing, Tuple{typeof(f),Int64}, nothing, svec(), 0x0000000000000001, 0xffffffffffffffff, MethodInstance for f(::Int64), true, true, false), Tuple{typeof(f),Int64,Vararg{Int64,N} where N}, nothing, svec(), 0x0000000000000001, 0xffffffffffffffff, MethodInstance for f(::Int64, ::Vararg{Int64,N} where N), false, true, true)

Run Code Online (Sandbox Code Playgroud)

我如何解释TypeMapEntry? 如何以编程方式访问它(我发现很难从输出中读取)?它做了多少专业?

tho*_*oly 7

MethodAnalysis包,今天早上刚刚注册,应该给你你需要的一切。(你问这个问题的时机非常好!)