You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently discovered every(), some() and none() and think they are great as I frequently used a pattern like any(map_lgl(...)). As @DavisVaughan pointed out in this PR they are unfortunately much slower than the map_lgl(...) pattern unless they exit early (benchmark copied from the other PR)
I've done some testing and I believe a significant chunk of overhead comes from two checks performed inside the loop. One is is_false()/is_true() called to check for early return, the other is is_bool() called to validate predicate's output. Both are necessary, so the only possible action is to try and reduce their overhead.
I've checked several options and the quickest one seems to be replacing both with a .Call() to a C function. Still slower than map_lgl() that doesn't have to check for early return, but an improvement nonetheless.
I'll try to write a C implementation of every() and friends anyways, to see if I can make it even closer; nevertheless, I meant to ask if the current improvement would be enough to warrant creating a PR.
I recently discovered
every()
,some()
andnone()
and think they are great as I frequently used a pattern likeany(map_lgl(...))
. As @DavisVaughan pointed out in this PR they are unfortunately much slower than themap_lgl(...)
pattern unless they exit early (benchmark copied from the other PR)It would be great to improve their performance so that they are as fast/faster than
map_lgl(...)
.The text was updated successfully, but these errors were encountered: