-
-
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
Make an isdense
trait
#54715
Comments
Duplicate of #54581? |
From
|
A few comments off the top of my head: Denseness should also be documented to say that it has a stride of 1. E.g. dense things should not be stored in reverse order, such that subsequent elements are placed on lower memory addresses. My proposal in #54581 is related. However, in that proposal, I don't include a trait like
I think the latter, more restrictive, |
If This could include Though I think also restricting |
I don't think that's possible, since that would write out SIMD alignment/padding in objects too. |
What about if @assert isbitstype(eltype(A))
Base.require_one_based_indexing(A)
B = Memory{eltype(A)}(undef, length(A))
GC.@preserve A B unsafe_copyto!(pointer(B), pointer(A), length(A))
@assert isequal(A, B) I think this is the same as the |
The first of these requirements definitely seems wrong. |
Without that there is a problem with A = Union{Float64,Int64}[1,2.5,3]
B = Memory{eltype(A)}(undef, length(A));
GC.@preserve A B unsafe_copyto!(pointer(B), pointer(A), length(A));
isequal(A,B) |
Density is orthogonal to many types (e.g. StaticArray, CodeUnits, SubArray, etc) so it makes more sense as a trait instead of an abstract type.
As a starting point,
Maybe also applies to strings?
See also:
The text was updated successfully, but these errors were encountered: