julia icon indicating copy to clipboard operation
julia copied to clipboard

Feature request: API to get the `Memory` underlying an `Array`

Open jakobnissen opened this issue 1 year ago • 2 comments

This can currently be accessed using parent(my_vec.ref), but this is internal. This is useful if one has a Vector, and needs acces to the lower-level, unresizable data backing it.

jakobnissen avatar Oct 18 '24 18:10 jakobnissen

I believe this should be added as a method of parent: parent(a::Array) = a.ref.mem?

vtjnash avatar Oct 18 '24 19:10 vtjnash

What works currently is obtaining the ref using cconvert and then fetching its parent.

julia> A = zeros(2);

julia> parent(Base.cconvert(Ptr, A))
2-element Memory{Float64}:
 0.0
 0.0

jishnub avatar Oct 19 '24 10:10 jishnub