Skip to content

Python NumPy array is not modified inside Julia #385

@alkalinin

Description

@alkalinin

I want to send large NumPy array from Python to Julia by a reference, not by copy. And probably this do not work.

main.py

import numpy as np

from julia import Main


def main():
    Main.include('test.jl')

    x = np.array([0, 1, 2, 3, 4])
    print(x)
    Main.double_array(x)
    print(x)

if __name__ == '__main__':
    main()

test.jl

function double_array(x)
    x[:] = x * 2
end

Result is

$ python main.py
[0 1 2 3 4]
[0 1 2 3 4]

Is there any possibility to send large numpy array from python to julia without copy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions