What does __precompile__ do?

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.)

1 Like

This is the wrong category for this.

You might be interested in SnoopCompile:

Check this:

3 Likes

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.

1 Like

Thanks, this clarified things for me!