# When do you all PyCall?

**URL:** https://discourse.julialang.org/t/when-do-you-all-pycall/47362
**Category:** New to Julia
**Created:** [September 27, 2020, 2:45pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362 "2020-09-27T14:45:02Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)
#### Post date: [September 27, 2020, 2:45pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/1 "2020-09-27T14:45:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [September 27, 2020, 3:42pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/2 "2020-09-27T15:42:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [September 27, 2020, 7:29pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/3 "2020-09-27T19:29:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [September 27, 2020, 8:21pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/4 "2020-09-27T20:21:31Z")

</div>

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:

```julia
ENV["OPENBLAS_NUM_THREADS"]="1"

```

---

<div class="post-metadata">

### Author: ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)
#### Post date: [September 27, 2020, 9:24pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/5 "2020-09-27T21:24:32Z")

</div>

Interesting, can I ask what’s available in Octave thats not in Julia? Or is it moreso to work with legacy code?

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [September 27, 2020, 9:30pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/6 "2020-09-27T21:30:03Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)
#### Post date: [September 28, 2020, 7:24pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/7 "2020-09-28T19:24:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![DrChainsaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drchainsaw/32/8497_2.png) [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)
#### Post date: [September 28, 2020, 9:31pm UTC](https://discourse.julialang.org/t/when-do-you-all-pycall/47362/8 "2020-09-28T21:31:18Z")

</div>

I use it to [test](https://github.com/DrChainsaw/ONNXmutable.jl/blob/master/test/serialize/serialize.jl) that exported ONNX models give the same output as the original (and re-imported) model when ran through [onnxruntime](https://github.com/microsoft/onnxruntime) 😛
