Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell what specializations are compiled for a method?

Tags:

julia

In the performance tip, it says f(x::Int...) = tuple(x...) will not specialize. It also suggests to use (@which f(...)).specializations to check the 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)

How do I interpret the TypeMapEntry? How can I access it programatically (I find it hard to read from the output)? How many specializations has it made?

like image 669
colinfang Avatar asked May 16 '20 13:05

colinfang


1 Answers

The MethodAnalysis package, registered just this morning, should give you everything you need. (Your timing in asking this question was excellent!)

like image 103
tholy Avatar answered Nov 03 '22 13:11

tholy