- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.7k
Description
In JuliaIO/HDF5.jl#1207 I am trying to create a custom resizable strided array to get the HDF5 C library, HDF5.jl, and ChunkCodecs.jl to all work together.
Looking at the docs:
julia/doc/src/manual/interfaces.md
Line 398 in 4d7da74
| ## [Strided Arrays](@id man-interface-strided-arrays) | 
Methods to implement Brief description strides(A)Return the distance in memory (in number of elements) between adjacent elements in each dimension as a tuple. If Ais anAbstractArray{T,0}, this should return an empty tuple.Base.unsafe_convert(::Type{Ptr{T}}, A)Return the native address of an array. Base.elsize(::Type{<:A})Return the stride between consecutive elements in the array. Optional methods Default definition Brief description stride(A, i::Int)strides(A)[i]Return the distance in memory (in number of elements) between adjacent elements in dimension k. 
I find the description of unsafe_convert and elsize confusing.
unsafe_convert says it should "Return the native address of an array", but this seems to be missing an important point that unsafe_convert needs to be paired with a cconvert.
Should all strided arrays also implement cconvert, or is there a default definition that can be documented here?
elsize says it should "Return the stride between consecutive elements in the array."
How is this different from stride(A, 1)?
I think the answer is in #38128 (comment) that elsize is "the multiplication factor for converting strides from elements to bytes". I think this should be the brief description.
Also, there seems to be a missing isstrided(A)::Bool function to check if an array supports the strided array interface.
Related issues: #54715 #36553 #51962
Also, here are some packages that implement the interface, but that don't seem quite right to me.
Doesn't parent(A) need to be replaced with Base.cconvert(Ptr{T}, parent(A)) and why is Base.unsafe_convert needed at all?
Base.elsize(::Type{PyArray{T,N,M,L,T}}) where {T,N,M,L} = sizeof(T)
Is there a case where this doesn't work?