I have two input files:
- a feature class with a number of polygons
- a raster
I want to do an Extract by Mask for each of the polygons in my feature class. Due to my data structure, I sometimes do not have an overlap between one of the polygons and the raster. Polygon 3 in the picture below does not have an overlap with the raster.

I already have a procedure that gives me the desired results, but I still have to do ExtractByMask for all of the polygons. All I do is not saving the temporary raster if the result is empty. Is there a way or a function that can check if a polygon and a raster intersect before I do the extract by mask procedure?
Below is my - probably way too complicated - code. It does the job, but it is very slow.
(The way I check if the raster is empty is by checking if the mean value and the standard Deviation is equal to 0)
<SPAN class="keyword token">import</SPAN> arcpy
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"my_workspace"</SPAN>
raster <SPAN class="operator token">=</SPAN> <SPAN class="string token">"my_raster"</SPAN>
fc_polygons <SPAN class="operator token">=</SPAN> <SPAN class="string token">"my_featureClass"</SPAN>
<SPAN class="comment token"># loop over polygons in the feature class fc_polygons</SPAN>
flds <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"OBJECTID"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"SHAPE@"</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>fc_polygons<SPAN class="punctuation token">,</SPAN> flds<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> curs<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> curs<SPAN class="punctuation token">:</SPAN>
objectId <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Extracting by mask for polygon: {0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>objectId<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
polygon <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN>flds<SPAN class="punctuation token">.</SPAN>index<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"SHAPE@"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># extracting for the polygon</SPAN>
new_raster <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>sa<SPAN class="punctuation token">.</SPAN>ExtractByMask<SPAN class="punctuation token">(</SPAN>raster<SPAN class="punctuation token">,</SPAN> polygon<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># if new_raster is empty discard the temporary raster, otherwise save it</SPAN>
<SPAN class="keyword token">if</SPAN> new_raster<SPAN class="punctuation token">.</SPAN>mean <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN> <SPAN class="operator token">and</SPAN> new_raster<SPAN class="punctuation token">.</SPAN>standardDeviation <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Delete_management<SPAN class="punctuation token">(</SPAN>new_raster<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"resulting raster is empty and is, therefore, discarded."</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
outname <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ras_buf_{0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>objectId<SPAN class="punctuation token">)</SPAN>
new_raster<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN>outname<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">" - saved raster as {0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>outname<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Edit: Curtis suggested using the extent of the raster, but my raster is not continuous. Below is another picture of how I imagine an intermediary step to look like. Only the polygons that overlap with the raster are selected:
