I’m extremely new to Julia (started learning it yesterday) and I’m currently in the process of trying to create a Python client for a game called Adventure Land. I have the client working, but there’s a single process within it that I feel takes too long and decided I’d try to embed Julia because it is supposedly faster.
However; I seem to have an issue because any time that the nested lists are of equal size, Julia converts them into a matrix instead of converting them into a nested Vector.
Using numpy has been suggested; but the nested lists are within a rather large dictionary object and I’d rather avoid having to install a whole separate package if at all possible. Is there some other way to control this conversion so that it converts directly to a vector instead of a matrix?
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.