-
Notifications
You must be signed in to change notification settings - Fork 28
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
Faster intersection of Indices #69
Comments
This did the job for me function Base.intersect(s1::AbstractIndices, s2::AbstractIndices)
length(s1) > length(s2) ? filter!(in(s2), copy(s1)) : filter!(in(s1), copy(s2))
end |
Thanks @pevnak One issue I had was trying to get the order of elements to come out the same either way. I don’t know if that is important, but so far I’ve been conservative with ordering issues. Not sure what other people’s opinions are? |
I cannot judge that. I am usually concerned with speed. |
Since there is a stable_sort and sort, would it make sense to have something similar? I apologize for abusing the comments, but the difference in speed I am getting in my application is enormous. I guess it might be possible to implement filtering for the opposite case, but it might be awful. One would first invalidate everything and then turn on only items that are in the other set. In this way, I guess, the iteration might go over the other set. I guess you got my idea, but not sure if it something that should be done. |
Yes perhaps.
There's no abuse here :) I, too, take performance seriously - we'll get this sorted. One consideration might be, when |
Another complication is the fact that either collection might be |
But it can be narrowed for types where this will be performant. |
I think that the intersection of
Indices
can be made trivially faster by ordering of arguments.Would it make sense?
The text was updated successfully, but these errors were encountered: