How does JuliaCall (PythonCall) protect Julia objects in Python code from Julia's GC?

Benny
Thu, 02 Oct 2025 22:12:50 +0000
General Usage

No practical purpose, just curious. For PythonCall in Julia code, it’s easy to imagine that a Julia wrapper increments an underlying CPython object’s reference count to protect it from CPython’s GC (I don’t know if this is actually true, so please correct me). But I can’t imagine how juliacall in Python code can protect underlying Julia objects from Julia’s GC when there isn’t an explicit Julia program to start tracing from. Is there a hidden juliacall cache of Julia objects somewhere, and if so can I get a link to its implementation?

5 posts - 2 participants