From the pycall docs:
From Julia to Python
Assuming you have NumPy installed (true by default if you use Conda), then a Julia
a::Arrayof NumPy-compatible elements is converted byPyObject(a)into a NumPy wrapper for the same data , i.e. without copying the data. Julia arrays are stored in column-major order, and since NumPy supports column-major arrays this is not a problem.However, the default ordering of NumPy arrays created in Python is row-major, and some Python packages will throw an error if you try to pass them column-major NumPy arrays. To deal with this, you can use
PyReverseDims(a)to pass a Julia array as a row-major NumPy array with the dimensions reversed . For example, ifais a 3x4x5 Julia array, thenPyReverseDims(a)passes it as a 5x4x3 NumPy row-major array (without making a copy of the underlying data).A
Vector{UInt8}object in Julia, by default, is converted to a Pythonbytearrayobject. If you want abytesobject instead, you can use the functionpybytes(a).From Python to Julia
Multidimensional NumPy arrays (
ndarray) are supported and can be converted to the native JuliaArraytype, which makes a copy of the data.Alternatively, the PyCall module also provides a new type
PyArray(a subclass ofAbstractArray) which implements a no-copy wrapper around a NumPy array (currently of numeric types or objects only). Just usePyArrayas the return type of apycallreturning anndarray, or callPyArray(o::PyObject)on anndarrayobjecto. (Technically, aPyArrayworks for any Python object that uses the NumPy array interface to provide a data pointer and shape information.)Conversely, when passing arrays to Python, Julia
Arraytypes are converted toPyObjecttypes without making a copy via NumPy, e.g. when passed aspycallarguments.
There is more information here .