basic = 'np.array([np.dot(dist[l],ind[l]) for l in xrange(dist.shape[0])])'
einsum = "np.einsum('ijk,ij->ik', ind, dist)"
tensor = 'np.tensordot(ind, dist, axes=[1, 1])[0].T'
print('tensor - total time:', min(timeit.repeat(stmt=tensor, setup=
    setup_code, number=10, repeat=3)))
print('basic - total time:', min(timeit.repeat(stmt=basic, setup=setup_code,
    number=10, repeat=3)))
print('einsum - total time:', min(timeit.repeat(stmt=einsum, setup=
    setup_code, number=10, repeat=3)))
Multiply high order matrices with numpy