I have an arcpy script which is run outside of ArcMap which constructs a feature class in the in-memory workspace. That empty feature class is later used as a template for several feature classes created in a file-based geodatabase. The script runs slow and profiling clearly shows the most time is used by the addFields function.
Fri Sep 20 17:30:50 2013 profile.stats
31613 function calls (29722 primitive calls) in 120.420 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
165 98.447 0.597 98.462 0.597 C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\_base.py:484(<lambda>)
Function was called by...
ncalls tottime cumtime
C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\_base.py:484(<lambda>) <- 10 0.000 0.011 C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\arcobjects\mixins.py:210(__init__)
2 14.767 14.767 C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\conversion.py:1497(FeatureClassToFeatureClass)
1 1.188 1.188 C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py:1615(CreateFeatureclass)
150 70.096 70.100 C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py:2916(AddField)
2 12.396 12.396 C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py:3637(Delete)
The question basically is, what is arcpy doing and why does it take so long? The above timing was taken when the script was executed from a mapped remote drive. When executed locally, the lambda in _base.py was responsible for only 10 seconds of total time which fell from 120 to 18 seconds. How would it matter though if the feature class is created in memory anyway?Any suggestions will be appreciated.