Rand-based Function Optimization

The optimization is specifically for tuples of lenght 1, 2, 3, and powers of 2 (including 4), which were easy enough to implement. For other lengths, you can definitely try to write optimizations and make a PR to Random. But since Julia 1.5, a more efficient algorithm is used to sample from an array (and from tuples of lengths not listed above), so it’s not obvious that specializations for tuples of length 5, 6, 7 can be faster than the generic algo (even the optimization for tuples of length 3 became close to irrelevant since Julia 1.5).

1 Like