-
-
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
@inbounds
annotations for filter
#30156
Conversation
Is travis MacOS build busted for everyone? |
@@ -2345,7 +2345,7 @@ function filter!(f, a::AbstractVector) | |||
|
|||
for acurr in a | |||
if f(acurr) | |||
a[i] = acurr | |||
@inbounds a[i] = acurr |
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.
Is there a policy for @inbounds
, AbstractArray
and the iteration protocol. I.e is it ok to segfault if someone implemented the iteration protocol erroneously?
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.
This is iterating over the index space of a: foreach(i -> a[i] = a[i], eachindex(a))
. I think it's OK to assume that is required to hold.
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.
AFAIK the policy is that AbstractArray
implementations which opt-in to using @boundscheck
assert that they are correct, so it's OK to crash if that's not the case. See #20469 and linked issues.
@@ -2345,7 +2345,7 @@ function filter!(f, a::AbstractVector) | |||
|
|||
for acurr in a | |||
if f(acurr) | |||
a[i] = acurr | |||
@inbounds a[i] = acurr |
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.
This is iterating over the index space of a: foreach(i -> a[i] = a[i], eachindex(a))
. I think it's OK to assume that is required to hold.
d18cc8f
to
41222bd
Compare
41222bd
to
33e0ffd
Compare
Should performance improvements like this one be backported? |
Yes |
No description provided.