Improving speed for thresholding of list of values (custom selection+extractSelect)

Thanks for your answer and taking the time.
my issue is that i need to do different things with each of the 20 groups, for each of them i will apply another function that will do a lot of checks and extract its external surface, so I need to be able to differentiate them.

So maybe create a mask, so each of the 20s have a different value and after filter using the mask, to get ‘separate’ intermediate outputs where i will call the function? do you think there would be a big improvement by doing this? I am asking as i am jumping a little bit to the void, not sure that it will be outperform and i will encounter a lot of bottle necks as i dont know vtk library to the level of doing what i am doing in paraview with the filters themselves…

  1. Compiling the value list into the script string (listOfValues={listOfValues}). For the 367,694-value call, just compile()-ing that literal is ~0.85 s — paid every time.

if i pass a filter and recover its values instead as i do with vtk_tgt i should get a speed up then? but not so much as the 367694 is the largest one by far, therefore the other ones wouls be less than 0.85 s so the speed up should be >>20s, no?

Also note your searchsorted→INDICES step is actually incorrect unless CellIds is already 0..N-1 (it feeds sorted positions as original indices); np.isin(gid_ref, values) → np.nonzero(…)[0] gives the correct original indices and was the fastest path in my test.

the cellIds beging in 0, but yes you are right, this part on your original code, was a little bit confusing for me to follow up. thanks again.

EDIT: also i just noticed that in pvbatch the overhead is crazy reduced! which is quite middle ground as i can check in paraview and if it works then scale up in pvpython. still appreciate your opinion but just posting it in case of others need.