<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script in Arc very slow + code improvement in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22655#M1769</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would this script help? &lt;/SPAN&gt;&lt;A href="http://arcscripts.esri.com/details.asp?dbid=16700"&gt;http://arcscripts.esri.com/details.asp?dbid=16700&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Mar 2011 16:16:30 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2011-03-28T16:16:30Z</dc:date>
    <item>
      <title>Python script in Arc very slow + code improvement</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22652#M1766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The following script takes 3 min to complete in Python on a shapefile that has 211 features. In Arc as a script in a Toolbox it takes 25 min &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Arc sits there when it gets to writing a particular feature and I'm not sure why. Is there extra checking and processing that occurs behind the scenes when you run a script as a tool in Arc?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script is pretty basic and I know there are some improvements I could do to speed it up; such as utilising a dictionary, so I'm not repeating MakeFeatureLayer for rows that have the same Area_m2 value, and actually working out how to query based on [Shape_Area], and get it to work! However, if it took 3 min in Arc I'd be happy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any insights into this would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy
import sys

arcpy.env.overwriteOutput = True

# Variables defined by the user

infc = arcpy.GetParameterAsText(0)
FGDBlocation = arcpy.GetParameterAsText(1)
FGDBname = arcpy.GetParameterAsText(2)
outfcname = arcpy.GetParameterAsText(3)
##lyrfile = arcpy.GetParameterAsText(4)

# Set other variables
##lyrfile = "G:\\GIS\\ModelBuilder\\Count_overlaps_tool\\CountOverlaps.lyr"
FGDB = FGDBlocation + "\\" + FGDBname + ".gdb"
output = FGDB + "\\" + outfcname
unionout = FGDB + "\\union"

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Run repair incase of empty geometries and self intersects
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RepairGeometry_management(infc)
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Repaired geometry"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create File Geodatabase to hold output featureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFileGDB_management(FGDBlocation, FGDBname)
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Created FGDB"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create temporary layer in memory for processing
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(infc, "in_memory\temp")
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Created temp layer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Union featureclass to process overlaps
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Union_analysis ("in_memory\temp", unionout)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create new field for storing overlap count to be populated
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(unionout, "Count", "SHORT", "2")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(unionout, "Area_m2", "TEXT", "", "", "15")
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Added fields"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Populate the new field
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(unionout, "Area_m2", "round(!Shape_Area!, 1)", "PYTHON_9.3")&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "error"

# Delete unrequired fields&amp;nbsp;&amp;nbsp;&amp;nbsp; 
arcpy.DeleteField_management(unionout, ["Id", "FID_Treatment", "Area", "Hectares"])&amp;nbsp;&amp;nbsp;&amp;nbsp; 
##print "Deleted fields"

# Create temporary layer in memory for processing
arcpy.MakeFeatureLayer_management(unionout, "in_memory\union")

# Create attribute index to speed up querying??
arcpy.AddIndex_management("in_memory\union", "Area_m2", "Area_m2Index")

# Setup cursor for update
rows = arcpy.UpdateCursor("in_memory\union", "", "", "Count; Area_m2")

for row in rows:

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the value from the Shape Area field
&amp;nbsp;&amp;nbsp;&amp;nbsp; area = row.getValue("Area_m2")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Clause used to create selection later&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; clause = "\"Area_m2\" = " + "'" + area + "'"
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print clause

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create temporary layer of all features with the same Area_m2 field value
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management("in_memory\union", "in_memory\temp", clause)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Count number of identical features to be used to populate count field
&amp;nbsp;&amp;nbsp;&amp;nbsp; featcount = arcpy.GetCount_management("in_memory\temp")
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print featcount

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Populate the Count field with the number of overlaps
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Count = str(featcount)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Update the row to write the Count value to the field
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "End of rows"

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete identical features
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DeleteIdentical_management(unionout, ["Area_m2"])
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Deleted duplicates"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Copy feature class from memory to a physical location
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management("in_memory\union", output)
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Copied features"

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(unionout)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("in_memory\temp")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("in_memory\union")
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Deleted redundant and temporary layers"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

del row
del rows&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 20:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22652#M1766</guid>
      <dc:creator>MarkPeacey</dc:creator>
      <dc:date>2011-03-23T20:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in Arc very slow + code improvement</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22653#M1767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The fact that your script runs eight times faster outside of AGD narrows things down. When you say "in Arc", do you mean as a script tool?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Right click on the tool and go to the Source tab. Make sure "Run Python script in process" is checked.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2011 19:46:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22653#M1767</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2011-03-25T19:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in Arc very slow + code improvement</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22654#M1768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes it's a script tool and I'm running it "in process" already. I'm thinking I'll have to re-write the script to utilise Arcpy geometry, based on the centroid of the features, to work out the number of polygons that intersect and see if I can get the same result with better speed. I'm still baffled by what Arc is doing, when it runs a script tool, to slow everything down by that order of magnitude.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got a few more test shapefiles so will try them when I have time, but I've heard from a colleague that it still runs very slowly in Arc.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Mar 2011 22:07:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22654#M1768</guid>
      <dc:creator>MarkPeacey</dc:creator>
      <dc:date>2011-03-27T22:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in Arc very slow + code improvement</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22655#M1769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would this script help? &lt;/SPAN&gt;&lt;A href="http://arcscripts.esri.com/details.asp?dbid=16700"&gt;http://arcscripts.esri.com/details.asp?dbid=16700&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2011 16:16:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22655#M1769</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-03-28T16:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in Arc very slow + code improvement</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22656#M1770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Would this script help? &lt;A href="http://arcscripts.esri.com/details.asp?dbid=16700"&gt;http://arcscripts.esri.com/details.asp?dbid=16700&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Chris, I did have a look at your script previously which gave me the idea of using a dictionary to prevent duplication. I think I'll implement that plus use the Geometry objects and hopefully that speeds things up.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Apr 2011 20:29:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22656#M1770</guid>
      <dc:creator>MarkPeacey</dc:creator>
      <dc:date>2011-04-03T20:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in Arc very slow + code improvement</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22657#M1771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Below is the drastically improved script which utilises a dictionary. Now takes less than 20 sec to process 10000+ features. There's still a number of improvements that could be made to the code, especially for the field deletes etc. as I've just specified them based on knowing the input files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Purpose: Allow for symbolic representation where helicopter bait drop swaths overlap. The more overlaps the higher the concentration applied.

import arcpy
import time
import sys

arcpy.env.overwriteOutput = True

print "Start time = " + time.asctime()

# Variables defined by the user

infc = arcpy.GetParameterAsText(0)
existFGDB = arcpy.GetParameterAsText(1)
existFGDBPath = arcpy.GetParameterAsText(2)
FGDBlocation = arcpy.GetParameterAsText(3)
FGDBname = arcpy.GetParameterAsText(4)
outfcname = arcpy.GetParameterAsText(5)

# Checks if the user has specified an existing geodatabase for the output. If so there's a change
# to the path variables so the existing geodatabase is used.

# Function to define path to existing geodatabase
def FGDBsource():
&amp;nbsp;&amp;nbsp;&amp;nbsp; global FGDB
&amp;nbsp;&amp;nbsp;&amp;nbsp; FGDB = existFGDBPath
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.AddMessage("Opted to put output in existing file geodatabase")

FGDB = FGDBlocation + "\\" + FGDBname + ".gdb"

# Call definition above if output selected to go into existing geodatabase
if existFGDB == 'true':&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Should be capital "T" but ArcMap returns lower case!
&amp;nbsp;&amp;nbsp;&amp;nbsp; FGDBsource()
# Otherwise create new geodatabase&amp;nbsp; 
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.AddMessage("Opted to create new file geodatabase")
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create new File Geodatabase to hold output featureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFileGDB_management(FGDBlocation, FGDBname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.AddMessage("Created new file geodatabase")

# Set script variables
unionout = FGDB + "\\union"
jointbl = FGDB + "\\join_table"
output = FGDB + "\\" + outfcname

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Run repair incase of empty geometries and self intersects
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RepairGeometry_management(infc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.AddMessage("Repaired geometry")
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create temporary layer in memory for processing
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(infc, "in_memory\temp")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Union featureclass to process overlaps
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Union_analysis ("in_memory\temp", unionout)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.AddMessage("Completed union")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create temporary layer in memory for processing
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(unionout, "in_memory\temp")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete unrequired fields
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DeleteField_management("in_memory\temp", ["Id", "Area", "Hectares"])

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create new field for storing overlap count to be populated
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management("in_memory\temp", "Count", "SHORT", "2")&amp;nbsp;&amp;nbsp;&amp;nbsp; 

##&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create attribute index to speed up querying
##&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddIndex_management("in_memory\temp", "Shape", "Shape_Index")
##&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcyp.AddMessage("Completed field changes and index build") 

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

# Dictionary for storing feature areas
countDict = {}

# For getting shapefield name
shapefldname = arcpy.Describe("in_memory\temp").ShapeFieldName

# Setup cursor for update
rows = arcpy.UpdateCursor("in_memory\temp", "", "", "Shape; Count")

print arcpy.AddMessage("Populating dictionary")

# For iterating through features
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get area of each feature using geometry object
&amp;nbsp;&amp;nbsp;&amp;nbsp; area = feat.area
&amp;nbsp;&amp;nbsp;&amp;nbsp; # If value is not in dictionary add it to dictionary with count = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if countDict.has_key(area) == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; countDict[area] = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; # If area value is in dictionary add + 1 to the count value and delete the row as it's a duplicate
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif countDict.has_key(area) == 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; countDict[area] = countDict[area] + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.deleteRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Error"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.AddMessage("Error: error with Shapefield value")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

# Setup another cursor for update
table = arcpy.UpdateCursor("in_memory\temp", "", "", "Shape; Count")

arcpy.AddMessage("Populating overlap 'Count' field")

# For iterating through non-duplicate features in order to write Count field
for r in table:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Getting area again
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = r.getValue(shapefldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; area = feat.area
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write count if count is not equal to zero
&amp;nbsp;&amp;nbsp;&amp;nbsp; if countDict[area] in range(1, 10):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r.Count = int(countDict[area])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table.updateRow(r)
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.AddMessage("Error: count value not between 1-10")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

# Copy feature class from memory to a physical location
arcpy.CopyFeatures_management("in_memory\temp", output)
arcpy.AddMessage("Created output featureclass")

# Add the output featureclass to the current map
arcpy.SetParameterAsText(6, output)
arcpy.AddMessage("Adding output to current mxd")

# Clean up redunadant layers and cursors to remove them from memory
arcpy.Delete_management("in_memory\temp")
arcpy.Delete_management(unionout)

del row, rows, r, table, arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "End time = " + time.asctime()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:55:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-arc-very-slow-code-improvement/m-p/22657#M1771</guid>
      <dc:creator>MarkPeacey</dc:creator>
      <dc:date>2021-12-10T20:55:33Z</dc:date>
    </item>
  </channel>
</rss>

