Precompiling submodules

Hi all,
I’m having a hard time with __precompile__(). I have a large project which consists of multiple submodules. To speed up the compilation process, I want to precompile some of the submodules, that would in theory support precompilation, and leave out the ones that do not. The overall project would not be precompilable.

__precompile__(false)
module MyPackage
    __precompile__()
    module A
    ....
    end
    #__precompile__(false)
    #module B
    #....
    #end
    using .A #, .B
end

This will, however, miserably fail, if __precompile__(false) appears even once at any place.
Is there a way to use partial precompilation at a submodule level, or is precompilation itself it restricted to packages? The docs are somewhat unclear about that, and do not distinguish between packages, modules and submodules.
I want to avoid splitting the main Package into a dozen smaller packages, only to add somewhat decent support for precompilation.

Thanks for your help,
Thomas

I don’t think this is possible. But what exactly is making your submodules impossible to precompile? For the most part, this can be fixed by moving any run-time initialization into the __init__() function.

I should be able to fix many to all precompilation issues using __init__(), however, this would involve additional complexity. Since I a) am lazy and b) wanted to keep the code simple I hoped for a small speedup by precompiling selected submodules.
This would make a nice feature, if it should ever be added.

You say it’s a large project, in that case, wouldn’t it be better from a software engineering point of view (for unit testing, etc) to move the submodules out into their own files as normal modules?
Then precompilation would just work.

1 Like