Could just use `npy_intp` as the type of `val`.