How to control type conversion from python to julia

Hi, welcome to the Julia community! If you haven’t already, it’s worth reading this.

I assume you’re using pyjulia? If so then yes, it does try to convert nested lists to higher dimensional arrays if the lengths agree - which is annoying if you have lists of lists that just happen to agree in length sometimes.

One workaround I think is to use a tuple of lists instead of a list of lists.

I think it’s also possible to wrap a Julia function in a way that calling it from Python doesn’t try to convert the arguments, so that you can convert them yourself, but I don’t remember how.

Alternatively you could try out juliacall, which is more conservative in converting data between Julia and Python.

Or if you’re just trying to accelerate one bit of a large Python program, maybe numba or cython are a better alternative than embedding Julia.

1 Like