Would Like to Improve Performance

315
0
09-24-2019 10:13 AM
JoeBorgione
MVP Emeritus

I'm working on a script in which I need to compare historical parcel ids in one table to a set of current parcel ids.  I'm using a couple of dictionaries and lists to do so, but the final dictionary I create seems to take forever. I'd like to speed that process up.   Here is the code:

import arcpy

bucket = r'J:\PythonDevelopment\ParcelsXY_Mojo\ParcelsMojo.gdb\LocalSlcoDept_ParcelsXY'
current = r'J:\PythonDevelopment\ParcelsXY_Mojo\ParcelsMojo.gdb\ParcelsLite_Points'

currentFields = ['PIN','XCOORD','YCOORD']
bucketFields = ['parcel_id','XCOORD','YCOORD']

currentDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(current,currentFields)}

selectField = ['parcel_id']
selectList = [r[0] for r in arcpy.da.SearchCursor(bucket,selectField)]

addThese = {key:value for key,value in currentDict.items() if key not in selectList}‍‍‍‍‍‍‍‍‍‍‍‍

bucket is the historical parcels, and current is what is current as of today. in bucket, the parcel id is in the field called parcel_id while in current it's called PIN.  The premise is if the PIN is already in parcel_id, skip it; if it's not there, append to addThese{} which an InsertCursor will eventually use to add into bucket.

Bucket has 431,000 records while current has 375,00 records.  Everything goes along nicely until line 14. Maybe I'm just being impatient, and 17 minutes is what it takes to plow through the list and dictionary....

That should just about do it....
0 Kudos
0 Replies