Another option is to use the materialize()
method:.
from qgis import processing
layer = QgsProject.instance().mapLayersByName('Langham_SPZs_v1_diss')[0]
outfn2 = "Langham_SPZs_final.shp"
layer.selectByExpression("number='2'")
layer2 = layer.materialize(QgsFeatureRequest().setFilterFids(layer.selectedFeatureIds()))
layer.selectByExpression("number='3'")
layer3 = layer.materialize(QgsFeatureRequest().setFilterFids(layer.selectedFeatureIds()))
processing.run("native:difference", {'INPUT' : layer3, 'OVERLAY' : layer2, 'OUTPUT': outfn2})
Note: this method is available since QGIS 3.0.
References: