I've got a few on demand scripts via the web that run ArcGIS in the background via Arcpy. Now, every one of these scripts takes a solid 15-30 seconds to run, which I find okay. After doing some trial and debugging on it, I find that 90% of the time spend running the script is taken importing Arcpy.
I've broken down a script I wrote here
- Import standard python modules like: os, cgi, time (less than 1 second)
- Grab web query and disseminate into a dictionary (less than 1 second)
- Import ArcPy (15 seconds)
- Import utm (less than 1 second)
- Convert lat long to utm (less than 1 second)
- Arcpy insert cursor, insert a new point into a feature class (less than 1 second)
- Arcpy update cursor, add attributes to a the new point (less than 1 second)
- Print web page based on outcome of query and Arcpy cursors (less than 1 second)
This whole script take about 16-20 seconds to run and most of that is spent importing Arcpy. The PC I am using is good, so what is the issue?
Is Arcpy so big that it actually takes this much time to import? Is there any other reason why the import takes so long? Also is there any work around to speed this up?