extracting section of grid by specific values of field

Hello,
I am have a specific need (in python): lets say i have a grid, with pressure values, and i want to extract the section where the pressure has specific values, [1,2,5] without other values, so threshold is out of the table as it will find a ‘section’.
my current approach (which works) is: using
QuerySelect(QueryString=f'(in1d({fieldName}, {listOfValues}))', FieldType=FieldType, InsideOut=False)
this will select the desired elements FieldType and then i can use extract selection.
it works, it is reliable but i would like to ask two questions in this regards:

  1. is there a more efficient way to do this? before i tested with a programable filter that will loop over all FielType elements which is ‘meh…’ in terms of performance.
  2. is there a way to do exactly this without the dependence of the renderviewer? (if i dont have a renderviewer open this will not work)

thanks in advance!

Is your data a double or an integer ?

was looking for the two, currently it is actually integer, but wanted to get it working for the two?

With an integer, if you data is stored as a vtkIdType, you can use the select by idtype value mechanism and select multiple idtype values.

It is not available in pvpython though, yet.