首页 > 解决方案 > 如何判断一个方法编译了哪些特化?

问题描述

性能提示中,它说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)

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

标签: julia

解决方案


今天早上刚刚注册的MethodAnalysis包应该可以为您提供所需的一切。(你问这个问题的时机非常好!)


推荐阅读