AnsweredAssumed Answered

performance of SearchCursor and da.SearchCursor

Question asked by ZachLiu on Sep 23, 2013
Latest reply on Sep 25, 2013 by lpinner
I set up a comparison between SearchCursor and da.SearchCursor, the code is like this:

import arcpy, time  shp = r"C:\Users\THINK\Desktop\python\Data\TOWNS.shp"  #da SearchCursor sTime = time.clock() rows = arcpy.da.SearchCursor(shp, ["TOWN", "TOTAL_SQMI"]) for row in rows:     town = row[0]     area = row[1]     print ("The area of %s is %s sq miles."%(town, area))    del row, rows  eTime = time.clock() tDiff = eTime - sTime print "da SearchCursor uses %s seconds."%(tDiff)    #SearchCursor sTime = time.clock() rows = arcpy.SearchCursor(shp) for row in rows:     town = row.getValue("TOWN")     area = row.getValue("TOTAL_SQMI")     print ("The area of %s is %s sq miles."%(town, area)) del row, rows  eTime = time.clock() tDiff = eTime - sTime print "SearchCursor uses %s seconds."%(tDiff)


I assume da.SearchCursor will be faster but it took more than 2 seconds while SearchCursor finished in just 0.5 second.
Is there something wrong with the test?

Outcomes