I can’t think of an obviously better way, no. Though the @. before the function is weird, I didn’t realize that syntax works.
Is it slow compared to other languages? If so it would be interesting to look in more to really push for performance.
EDIT: The use of @btime here might not be the most reliable, since you are constructing an anonymous function inside the call. Maybe wrap in another function and see how it goes?
It is with ByRow instead of broadcasting. I think both filter and ByRow might enable some sort of multi-threading that isn’t being picked up with the broadcasting?
If you add another 0 to the length of test_data they should be the same. So I think you are seeing the complicated internal logic of subset compared to filter. This is a fixed cost and won’t matter for bigger data frames.