add wrap function which is the safe counterpart to unsafe_wrap.#52049
add wrap function which is the safe counterpart to unsafe_wrap.#52049vtjnash merged 16 commits intoJuliaLang:masterfrom
wrap function which is the safe counterpart to unsafe_wrap.#52049Conversation
|
I wish we could call this function EDIT: yipes, I didn't realize these internals still had so many gotchas. Thank you for the review, @vtjnash. |
base/array.jl
Outdated
| mem = ref.mem | ||
| mem_len = length(mem) | ||
| len = Core.checked_dims(dims...) | ||
| @boundscheck mem_len >= len || invalid_wrap_err(men_len, dims) |
There was a problem hiding this comment.
should this check be behind a @boundscheck or should it just always be there?
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
|
okay this should be ready now |
|
@vtjnash do you concur? |
|
Should we consider adding support to |
|
I'm not sure it'd really be that useful for That's why I wanted a way to wrap without re-allocating the memory slice as in #52048 |
|
I guess actually we could do it for 1D views without allocations. But it's kinda unsatisfying to have it only be nice for 1D. |
I thought that's reasonable in the light that `view` was not implemented: JuliaLang#52049 (comment)
This gives users a way to create new
Arrays out of existingMemorysinceArrayhas no constructors still.There's a@test_brokenin there due to #52048