Since it seems a bit related, take a look here Fastest way to fetch an index where we designed alternatives to searchsortedlast it might give you more ideas
Since it seems a bit related, take a look here Fastest way to fetch an index where we designed alternatives to searchsortedlast it might give you more ideas