-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add wrap
function which is the safe counterpart to unsafe_wrap
.
#52049
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Array
s out of existingMemory
sinceArray
has no constructors still.There's a@test_broken
in there due to #52048