Could this simple function go faster?

It depends on the problem sometimes is faster to just do the computation (if the computation are not very intensive…) but in your case I guess using a precomputed array is the way to go :+1:.

Looking at your code when I see prod(P.BINS[CartesianIndex.(k_minus_one_in_deg,j_arr)] it suggest that maybe there is a way to reorder the computations so that instead of calling prod you can do a multiplication for each k.

But to be fair I don’t understand fully what your code does because I’m not used to cartesianindex stuff :sweat_smile: