Skip to content

Commit d740837

Browse files
MilesCranmerBotMilesCranmercjdoris
authored
Precompile the first calls of a JuliaCall session (#837)
A new JuliaCall session usually starts with `jl.<name>` on `juliacall.Main` or `jl.seval(...)`. PythonCall's package image had no compiled code for either method, so every session compiled them at runtime, which took about a second. Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com> Co-authored-by: Christopher Rowley <cjdrwly@gmail.com>
1 parent 992758d commit d740837

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
* Improved TTFX in JuliaCall.
45
* Minimum supported Python version is now 3.11.
56

67
## 0.9.37 (2026-10-12)

‎src/JlWrap/any.jl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function pyjlany_getattr(self, k_::Py)
2121
Py(getproperty(self, k))
2222
end
2323
pyjl_handle_error_type(::typeof(pyjlany_getattr), self, exc) = pybuiltins.AttributeError
24+
# `jl.<name>` on `juliacall.Main` is often the first call of a JuliaCall session.
25+
precompile(pyjlany_getattr, (Module, Py))
2426

2527
function pyjlany_setattr(self, k_::Py, v_::Py)
2628
k = Symbol(pyjl_attr_py2jl(pyconvert(String, k_)))

‎src/JlWrap/module.jl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ end
1212
function pyjlmodule_seval(self::Module, expr::Py)
1313
Py(Base.eval(self, Meta.parseall(strip(pyconvert(String, expr)))))
1414
end
15+
# `jl.seval(...)` is often the first call of a JuliaCall session.
16+
precompile(pyjlmodule_seval, (Module, Py))
1517

1618
function init_module()
1719
jl = pyjuliacallmodule

0 commit comments

Comments
 (0)