Requires.jl and precompilation

I have a question, about Requires.jl and precompilation. Say I have the following package:

module AxisArrayConversion
__init__() = @require AxisArrays=... include("axis_arrays.jl")

Then things defined in the “axis_arrays.jl” file will not get precompiled. Correct so far or is it more complicated?

Now suppose I have in addition another package:

module OtherPackage
using AxisArrays
using AxisArrayConversion

function f(...)
    # use stuff defined in axis_arrays.jl file

Will OtherPackage.f get precompiled?

1 Like

The term precompile is a little confusing, because it means different things. The standard Precompiling SomePkg... message by default means its caching the method definitions etc in your package. Optionally you can also save the type-inferred code, but that requires that you either (1) use the methods while the package is being built, or (2) explicitly call precompile while the package is being built.

To answer your direct question: the @require example, your methods will not even be cached, let alone in type-inferred form. In the second case, the method definition for f will be automatically cached. To cache the type-inferred form you’ll have to emit precompile directives.