I have a script in ArcPy that iterates through a set of intersection points and determines if all intersecting streets have the same attribute value in the CROSSLTS field, and if they do, sets the the intersection point's MarkForProcessing field value to 1. if the intersecting segments do not have identical CROSSLTS values, it sets the MarkForProcessing field value to 0.
When I run this script from the Python window of ArcMap, it takes 2 hours and I get an "out of memory" message before it completes. when i run it from PyCharm, it takes roughly 10 minutes, but the MarkForProcessing field is never updated.
Can someone could take a look?
import arcpy workspace = 'C:\SRC\Bikestress\LTS classification.gdb' arcpy.env.overwriteOutput = True ##check if all elements in a list are identical, returns true if so. def checkEqual(lst): return lst.count(lst) == len(lst) arcpy.MakeFeatureLayer_management(r'C:\SRC\Bikestress\LTS classification.gdb\Intersections','INTERSECTIONSLYR','',workspace) arcpy.MakeFeatureLayer_management(r'C:\SRC\Bikestress\LTS classification.gdb\roadmidsplit2','STREETSLYR','',workspace) Intersectionfields = ["CONTROLTYPE","GLOBALID","MarkForProcessing","SHAPE@"] StreetsFields = ["CROSS_LTS"] count = 0 with arcpy.da.UpdateCursor('INTERSECTIONSLYR', Intersectionfields) as IntersectionCursor: for Intersection in IntersectionCursor: count += 1 if Intersection not in ["4STOP", "PED", "TRAFFICSIG"]: # select the intersection of the current row, and all adjacent segments arcpy.SelectLayerByLocation_management('STREETSLYR', "INTERSECT", Intersection, "", "NEW_SELECTION") CROSSLIST =  #make sure selection is not empty desc = arcpy.Describe('STREETSLYR') if desc.FIDSet == '': with arcpy.da.SearchCursor('STREETSLYR', StreetsFields) as StreetCursor: for Street in StreetCursor: CROSSLIST.append(Street) if len(CROSSLIST) != 0: if not checkEqual(CROSSLIST): Intersection = 1 else: Intersection = 0 IntersectionCursor.updateRow(Intersection) if str(count)[-2:] == "00": print(str(count) + " records processed") print('writing intersections layer...') arcpy.CopyFeatures_management("INTERSECTIONSLYR", r'C:\SRC\Bikestress\LTS classification.gdb\IntersectionsUpdated') print("done")