# Calling Julia from Python without severe startup

**URL:** <https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949>\
**Category:** Performance\
**Created:** [March 14, 2025, 1:18pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949 "2025-03-14T13:18:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Job](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter_job/32/215169_2.png) [@Peter\_Job](https://discourse.julialang.org/u/Peter_Job)\
**Post date:** [March 14, 2025, 1:18pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949/1 "2025-03-14T13:18:15Z")

</div>

Hello!

I’m writing this issue because when I googled around this issue, I found a few different solutions, and all of them have been either painful or slow. Hopefully a discoverable thread with the details of how we are able to use Julia from Python without incurring severe startup times, whilst still having a decent development loop will exist now.

My usecase is a Qt GUI app, created with the PyQt interface. This app is showing some information which is gathered from a file and some plots of a simulation which is running in Julia when the app starts.

It seems like Julia should be a good language for this. The simulations have been generally pleasant to write, and run efficiently once they are compiled.

At the moment, in the app (in an imported python file), we use the pattern

```py
import juliacall
jl = juliacall.newmodule("MyModulePy")
jl.seval("""
using PythonCall
using MyModule
""")

```

where MyModule is the module containing the simulations. We then call the simulations with `jl.MyModule.simulation_function(args)`.

Doing some naive logging of timing, I get

```julia
Juliacall is imported in 2.652151107788086
Juliacall starts in 1.3792328834533691
The using statements took 2.039438247680664

```

The JIT compilation of the simulations takes a significant amount of time (20+ seconds). I’m aware that starting Julia with a sysimage of the simulation module can improve this significantly.

What’s the right way to improve the time taken for these steps, especially the startup of juliacall?

---

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [March 14, 2025, 2:52pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949/2 "2025-03-14T14:52:25Z")

</div>

Use [GitHub - Suzhou-Tongyuan/jnumpy: Writing Python C extensions in Julia within 5 minutes.](https://github.com/Suzhou-Tongyuan/jnumpy) and [Home · PrecompileTools.jl](https://julialang.github.io/PrecompileTools.jl/stable/) .

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [March 14, 2025, 3:55pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949/3 "2025-03-14T15:55:26Z")

</div>

If you make your module a package and add instructions for precompilation you might be able to move most of that time to the installation process only.

---

<div class="post-metadata">

**Author:** ![Peter\_Job](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter_job/32/215169_2.png) [@Peter\_Job](https://discourse.julialang.org/u/Peter_Job)\
**Post date:** [March 14, 2025, 4:15pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949/4 "2025-03-14T16:15:08Z")

</div>

> <https://github.com/Suzhou-Tongyuan/jnumpy/blob/main/TyPython/src/Utils.DevOnly.compiled.jl>

This looks like malware.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [March 14, 2025, 4:43pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949/5 "2025-03-14T16:43:24Z")

</div>

The discourse spam filter thought so too. It’s indeed very odd.

In the context of juliacall, as a first pass, I’d use PackageCompiler to [create a sysimage](https://julialang.github.io/PackageCompiler.jl/dev/sysimages.html) along with the [`-X juliacall-sysimage=<file> `](https://juliapy.github.io/PythonCall.jl/stable/juliacall/#julia-config) flag.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [April 12, 2026, 4:59pm UTC](https://discourse.julialang.org/t/calling-julia-from-python-without-severe-startup/126949/6 "2026-04-12T16:59:37Z")

</div>

The startup time is long without importing any Julia package:

```shell
$ time python -c "from juliacall import Main as jl"

real	0m2.355s
user	0m3.104s
sys	0m0.156s

```

So creating a system image for your Julia package doesn’t completely solve the problem. You’ll need to somehow create a system image for whatever Julia code that’s executed by the juliacall python module at startup.
