diff --git a/CHANGELOG.md b/CHANGELOG.md index b7673ae1..d5a0c702 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## Unreleased +* The first call from Python in a new JuliaCall session no longer compiles + `jl.` lookup on a module or `jl.seval`, saving about a second. * Bug fixes. ## 0.9.36 (2026-09-18) diff --git a/src/JlWrap/any.jl b/src/JlWrap/any.jl index 96a6a3d2..c0a4244c 100644 --- a/src/JlWrap/any.jl +++ b/src/JlWrap/any.jl @@ -21,6 +21,8 @@ function pyjlany_getattr(self, k_::Py) Py(getproperty(self, k)) end pyjl_handle_error_type(::typeof(pyjlany_getattr), self, exc) = pybuiltins.AttributeError +# `jl.` on `juliacall.Main` is often the first call of a JuliaCall session. +precompile(pyjlany_getattr, (Module, Py)) function pyjlany_setattr(self, k_::Py, v_::Py) k = Symbol(pyjl_attr_py2jl(pyconvert(String, k_))) diff --git a/src/JlWrap/module.jl b/src/JlWrap/module.jl index 2f636e08..5fb1aa8f 100644 --- a/src/JlWrap/module.jl +++ b/src/JlWrap/module.jl @@ -12,6 +12,8 @@ end function pyjlmodule_seval(self::Module, expr::Py) Py(Base.eval(self, Meta.parseall(strip(pyconvert(String, expr))))) end +# `jl.seval(...)` is often the first call of a JuliaCall session. +precompile(pyjlmodule_seval, (Module, Py)) function init_module() jl = pyjuliacallmodule