I've been passing the results of selections against layers directly to the arcpy.da.UpdateCursor, and noticed that the performance is terrible. I love the convenience of not deriving some whacky SQL to tell the cursor exactly what I want to update...but at this point, the juice ain't worth the squeeze.
Any tips on making this work? The process is usually something like
selected_stuff = arcpy.GetParameter('selection') # feature layer input with a selection applied
metrics = {id: metric for id, metric in results} # parse through some table of results to get the stuff I wan to update
with arcpy.da.UpdateCursor(
selected_stuff,
field_names=['id', 'metric'],
) as i_cursor:
for row in i_cursor:
metric = metrics.get(row[0])
if metric and metric != row[1]:
row[1] = metric
i_cursor.updateRow(row)