Chris,Thanks for the tips.Re: suggestion 1, I don't think I can use SelectLayerByAttribute because I have a standalone table.Re: suggestion 2, I thought this might be the winner, since I do have a series of searches to run over the same table. However, the overhead in creating the 2.3mil key:value pairs was REALLY expensive. I let my script run for about 6-7 minutes, and the dictionary hadn't yet been created...let alone complete any searches.I thought I might be able to leverage some functionality from numpy, since all my values are numeric. Turns out there is a pretty cool way to load an array (my_array = numpy.fromiter) but that, too, was quite expensive. For comparison sake, I used a smaller table with ~160K records. For each of the trials, I started a fresh ArcMap session. I'm not sure if the individual methods are coded the best, but here's the times and code to run 10 searches over the same table:by cursor:14.17sby making table and counting: 28.4sby dictionary: 98.5sfrom arcpy import *
from stopwatch import clockit
from numpy import *
@clockit
def do_search_by_count(table):
count = 0
for i in range(100,1000,100):
searchstring = "NEAR_DIST < " + str(i)
count += make_table_and_count(table, searchstring)
print "done by count: " + str(count)
return count
@clockit
def do_search_by_cursor(table):
count = 0
for i in range(100,1000,100):
searchstring = "NEAR_DIST < " + str(i)
count += cursor_search_count(table,searchstring)
print "done by cursor: " + str(count)
return count
@clockit
def do_search_by_dict(table):
lookupDict = create_dict(table)
count = 0
for i in range(100,1000,100):
count += count_dict(lookupDict,i)
print "done with dict: " + str(count)
return count
@clockit
def make_table_and_count(table,searchstring):
arcpy.MakeTableView_management(table,"mytv5k",searchstring)
x = int(str(arcpy.GetCount_management("mytv5k")))
return x
@clockit
def cursor_search_count(table,searchstring):
rows = arcpy.SearchCursor(table,searchstring)
count = 0
for row in rows:
count += 1
return count
@clockit
def create_dict(table):
lookupDict = {}
searchRows = arcpy.SearchCursor(table)
for myrow in searchRows:
lookupDict[myrow.OBJECTID] = [myrow.NEAR_DIST]
del myrow
del searchRows
print "created dict"
return lookupDict
@clockit
def count_dict(lookupDict,dist):
count =0
for k,v in lookupDict.iteritems():
if v[0] < dist:
count += 1
return count
Thanks again for the tips.Mike