How to pass numpy array to compiled expression member variable?

One issue is:

v = np.array([1., 2., 4., 8.], dtype=float)
exp.arr = v
print(exp([0.,0.,0.]))   # Prints 15, OK
v *= 2
print(exp([0.,0.,0.]))   # Still prints 15, not 30
exp.arr = v
print(exp([0.,0.,0.]))   # Prints 30, OK

So I guess exp.arr = v actually involves some copy, right? Is there a way to make the two variables (python & c++) linked to the same data? Thanks again so much.

1 Like