Select to view content in your preferred language

Running ArcPy script with unsaved edits = massive processing speed boost

1633
7
07-01-2020 07:32 PM
EC1
by
Occasional Contributor

Hello,

I have written a script which snaps points to lines, it is a more complex version of the Snapper tool, except it snaps points to a specific end of a line depending on its orientation and connections to other lines.

The script works fine as is. I use a With statement to open the update cursor and then a for loop, to loop through the points, each point then searches for lines within a given distance to find an appropriate line to snap said point to. I am not using edit.start/edit.stop as I believe that the With opening the updateCursor is handing this. 

Now, I am running the script while I have the data open and visible on ArcPro. When I run the script normally I do not have any unsaved edits from manual editing (so the save button under the edit ribbon is greyed out). When I run the script it takes about 10 seconds per point to process and snap a point to a nearby line (if there is one). Once this is finished the edits are saved automatically (the save button under the edit ribbon is still greyed out)

But. If I edit a point manually, and I have unsaved edits open (the save button in edit ribbon is coloured) and run the script, it processes at about 10 times faster than before, taking only one second per point to process. I have not noticed any issues with the data which has been processed this way. I can hit save after this processing and all changes are saved. 

This has lead me to believe that somehow my script is committing saves for each point it processes (when I have no unsaved edits) and making my script run much slower than it could.

My question is: How can I impliment what is happening here in my script so I do not need to do this weird trick to get faster processing, 

EDIT: attached script

Tags (3)
0 Kudos
7 Replies
DanPatterson
MVP Esteemed Contributor

Are you using the data access editor?

Editor—Data Access module | Documentation 


... sort of retired...
0 Kudos
EC1
by
Occasional Contributor

Currently, no. 

But I have previously added this to the script to test, and nothing changed speed wise.

0 Kudos
MatthewDobson
Frequent Contributor

EC, what about starting an edit session programmatically? Editor

0 Kudos
DanPatterson
MVP Esteemed Contributor

Matthew Dobson‌ I suggested that already


... sort of retired...
0 Kudos
MatthewDobson
Frequent Contributor

Apologies Dan, I misread and thought you had suggested the .da module.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Without sharing any specifics, like back-end data store or code structure snippets, it is hard for people to share specific suggestions.  Given that ArcPy DA cursors were created to improve performance, and have been demonstrated to significantly improve performance in many situations, saying that using old/legacy cursors and new/DA cursors makes no difference leads me to believe the issue isn't really related to cursors themselves.

0 Kudos
EC1
by
Occasional Contributor

Hello, 
I can share the whole script if that would help - I've just got to figure out how to. 

EDIT: See attached

0 Kudos