Example demonstrating how to setup a precompile workload involving PythonCall.jl
- Trigger the precompilation, e.g.
julia --project=. -e "using Pkg; Pkg.precompile()"
- Check that on package import, there is already a python-specific method instance
~/repos/PythonCallPrecompileExample$ julia --project=.
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.10.3 (2024-04-30)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using PythonCallPrecompileExample # assume it was already precompiled
julia> PythonCallPrecompileExample.a_julia_function
a_julia_function (generic function with 1 method)
julia> methods(PythonCallPrecompileExample.a_julia_function)[1]
a_julia_function(xs)
@ PythonCallPrecompileExample ~/repos/PythonCallPrecompileExample/src/PythonCallPrecompileExample.jl:5
julia> methods(PythonCallPrecompileExample.a_julia_function)[1].specializations
svec(MethodInstance for PythonCallPrecompileExample.a_julia_function(::Any), MethodInstance for PythonCallPrecompileExample.a_julia_function(::PythonCall.Wrap.PyArray{Float64, 2, true, false, Float64}), nothing, nothing, nothing, nothing, nothing)
- Additionally, check like this
julia> using PkgCacheInspector
julia> info = info_cachefile("PythonCallPrecompileExample")
Contents of /home/ggoretkin/.julia/compiled/v1.10/PythonCallPrecompileExample/pwWHM_icoBu.so:
modules: Any[PythonCallPrecompileExample]
3954 new specializations of external methods (Base 67.1%, UnsafePointers 7.3%, PythonCall.Convert 6.7%, ...)
419 external methods with new roots
6255 external targets
4298 edges
file size: 4121616 (3.931 MiB)
Segment sizes (bytes):
system: 1472636 ( 44.54%)
isbits: 1632796 ( 49.39%)
symbols: 6439 ( 0.19%)
tags: 20745 ( 0.63%)
relocations: 163206 ( 4.94%)
gvars: 6512 ( 0.20%)
fptrs: 3880 ( 0.12%)
Image targets:
alderlake; flags=0; features_en=(sse3, pclmul, ssse3, fma, cx16, sse4.1, sse4.2, movbe, popcnt, aes, xsave, avx, f16c, fsgsbase, bmi, avx2, bmi2, adx, clflushopt, clwb, sha, pku, waitpkg, shstk, gfni, vaes, vpclmulqdq, rdpid, movdiri, movdir64b, serialize, sahf, lzcnt, prfchw, xsavec, xsaves, avxvnni, ptwrite)
julia> :a_julia_function in map(spec -> spec.def.def.name, info.new_specializations)
true