So I’ve been brushing up a little bit on my python, but doing so under the guise of julia projects that require/benefit from pycall so I don’t rust out any skills. Had me thinking, when do other people consider using PyCall in a project and how do they typically do so? Similarly, I’m also interested in cases where people find a good use for PyJulia. Although I am pretty doubtful there will be a lot of users here who have opinions on this, I figured I’d ask :).
Use cases I’ve found so far:
- Interfacing with hardware, like a computer microphone or speakers.
- When OOP “feels right”: Ie: I wrote a little python class for loading batches of training data. Yes, this can be done in Julia, but, some of the OOP paradigms in python are very clean and do not need best-in-class performance.
- When there is “advanced” functionality for doing essential tasks that we just don’t have in our ecosystem and I don’t have time to roll my own. An example of this could be needing GTK for a function/action. Yes, I am aware Julia has wrappers to GTK but my last attempt at using them was pretty painful and lead to me realizing I couldn’t use it for the task I needed too, trying to grok the code and realizing there were almost no docstrings/comments in the entire package and found doing what I needed via the python API to take ~30minutes.
It’s interesting to think about but, when does an application/project truly benefit from being mostly python vs sometimes calling out to Julia, or the opposite, when does an application/project benefit from being mostly Julia and sometimes calling out to python.
I use PyCall.jl pretty much only when I need to use code my colleagues wrote in Python and there is no reason to reimplement it in Julia. I recall using some clustering library in Python also that was too complex for me to bother reimplementing it.
Python also has low start-up lag which I’ve come to appreciate lately. In some situations this can be worth considering.
I use PyJulia for plotting + data analysis on Python side (mostly when the data is too big for VegaLite.jl to handle). Although I do respect all the hard work put in Julia’s plotting ecosystem, my personal UX with matplotlib + seaborn is still much smoother. I kinda feel bad saying that I still do plots in Python. But hey, who maintains PyJulia if I don’t use Python
As for the generic question on when to use PyCall or PyJulia, I’d say whenever you find a non-trivial useful package in PyPI.
These days I use PyCall actually to call Octave, a MATLAB clone. That is I use Oct2Py.
FYI: if you’re doing that, and get “Session died” (with no line number or why), you may need to add to your Julia code:
Interesting, can I ask what’s available in Octave thats not in Julia? Or is it moreso to work with legacy code?
There’s nothing interesting that I know of in Octave, it’s only a means to an end. Yes, I’m porting code from MATLAB. It didn’t even run in MATLAB, in Linux for me (only for Windows users because of Excel support). Octave wasn’t much better that way, so I use Julia Excel reader.
Palli, I feel your pain coping with legacy code; thanks for explaining. I was optimistic and hoped that there was something cool in Octave we were missing in Julia and could write it up.
I use it to test that exported ONNX models give the same output as the original (and re-imported) model when ran through onnxruntime