What does __precompile__ do?

question

#1

I am curious to understand better how __precompile__() works. For example if I have a module containing

f(x::Int) = ...
f(x::Number) = ...
f(x) = ...
g(x::Float32) = f(x)

Is it true that machine code for f(::Int) is cached? What about f(::Float32)? What is done with the other declarations? Lowering? Can I control for which signatures machine code is cached (e.g. please cache machine code for all signatures occurring while executing runtests.jl.)


#2

This is the wrong category for this.

You might be interested in SnoopCompile:


#3

Check this:


#4

No. Only the inference result is cached.

You can’t control what machine code is cached but you can use precompile to control what inference is cached.


#5

Thanks, this clarified things for me!