<?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: Is there a way to speedup the following code in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134702#M10568</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome thanks,&amp;nbsp;I haven't seen a&amp;nbsp;search cursor used&amp;nbsp;in that way before. I would assume the Dissolve FC could be used directly into the Search Cursor instead of using the Copy Features. Thus eliminating an extra step?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Mar 2019 06:21:10 GMT</pubDate>
    <dc:creator>AndrewNeedham1</dc:creator>
    <dc:date>2019-03-14T06:21:10Z</dc:date>
    <item>
      <title>Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134696#M10562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Back story, this code is part of a much larger script which&amp;nbsp;loops a few thousand times and takes a few days to finish&lt;/P&gt;&lt;P&gt;I'm currently going through the code and trying to it speed up where possible. Can the following code be speed up?&lt;/P&gt;&lt;P&gt;I know arcpy.da curses are fast but can they be used here?&lt;/P&gt;&lt;P&gt;Edit: This is using ArcGIS 10.3.1 and can't be transferred to ArcPro&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV style="color: #f8f8f2; background-color: #282a36; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #6272a4;"&gt;# select Lines&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;whereClauseSort &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"""&lt;/SPAN&gt;&lt;SPAN style="color: #bd93f9;"&gt;{}&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt; IN (1,2,3) AND &lt;/SPAN&gt;&lt;SPAN style="color: #bd93f9;"&gt;{}&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt; = 'Pass' """&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;.format(&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'Sorting'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'Group2'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;selectionLineFC &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #8be9fd;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"in_memory&lt;/SPAN&gt;&lt;SPAN style="color: #bd93f9;"&gt;\l&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;ine"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;arcpy.Select_analysis(selectionFC, selectionLineFC, whereClauseSort)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #6272a4;"&gt;# Dissolve selected lines&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;Dissolve1 &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #8be9fd;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"in_memory\Dissolve1"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;arcpy.Dissolve_management(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; selectionLineFC, Dissolve1, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"Angle;BEARING"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"Sorting COUNT;Seam First"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"MULTI_PART"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"DISSOLVE_LINES"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #6272a4;"&gt;# add attributes&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;arcpy.AddField_management(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; Dissolve1, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"Length"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"LONG"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"Length"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"NULLABLE"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"NON_REQUIRED"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;arcpy.CalculateField_management(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; Dissolve1, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"Length"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"round(!shape.length@meters!,10)"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"PYTHON_9.3"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #6272a4;"&gt;# Sort Dissolve selected lines &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;sort &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #8be9fd;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"in_memory\Sort1"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;arcpy.Sort_management(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'Dissolve1'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, sort,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'Length DESCENDING;Angle ASCENDING;COUNT_Sorting ASCENDING'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'UR'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #6272a4;"&gt;# Select first record&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;sort2 &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #8be9fd;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"in_memory\Sort2"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;sel &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; arcpy.Select_analysis(sort, sort2, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'OID = 1'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #6272a4;"&gt;# Buffer first record&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;convexHullBuff &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #8be9fd;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"in_memory&lt;/SPAN&gt;&lt;SPAN style="color: #bd93f9;"&gt;\c&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;onvexHullBuff"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;convexHullbuff &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; arcpy.Buffer_analysis(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; sel, convexHullBuff, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'200 Meters'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'FULL'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'ROUND'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'NONE'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'#'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'PLANAR'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #6272a4;"&gt;# CONVEX_HULL of Buffered first record&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;ConvexHull &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #8be9fd;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"in_memory&lt;/SPAN&gt;&lt;SPAN style="color: #bd93f9;"&gt;\C&lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;onvexHull"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt;convexHull &lt;/SPAN&gt;&lt;SPAN style="color: #ff79c6;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt; arcpy.MinimumBoundingGeometry_management(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #f8f8f2;"&gt; convexHullbuff, ConvexHull, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;"CONVEX_HULL"&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'NONE'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'#'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #f1fa8c;"&gt;'NO_MBG_FIELDS'&lt;/SPAN&gt;&lt;SPAN style="color: #f8f8f2;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2019 04:30:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134696#M10562</guid>
      <dc:creator>AndrewNeedham1</dc:creator>
      <dc:date>2019-03-14T04:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134697#M10563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is your end goal? Can you explain the purpose of those blocks of code?&lt;/P&gt;&lt;P&gt;Do you get different results for instance, if you determine the convex hull, then buffer vs the way you have it?&lt;/P&gt;&lt;P&gt;If you have complex shapes, the more points you have the longer the buffer is going to take&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, In some cases, just working with the arcpy geometry methods and properties is faster than calling the arctoolbox tool that does the same thing (eg, like a dissolve).&amp;nbsp; Other times using numpy for geometry functions is orders of magnitude faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2019 05:05:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134697#M10563</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-03-14T05:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134698#M10564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The end goal is to run the script faster that it currently is. The order needs to be maintained such as, if you don't buffer the selected line\s (multipart) the convex hull will fail on a single line.&lt;/P&gt;&lt;P&gt;Yes the goal would be to use &lt;SPAN style="background-color: #ffffff;"&gt;arcpy geometry methods, but I am unaware of the&amp;nbsp;&lt;/SPAN&gt;syntax/code for&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;arcpy geometry methods to do a dissolve, do you have an example of this?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2019 05:35:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134698#M10564</guid>
      <dc:creator>AndrewNeedham1</dc:creator>
      <dc:date>2019-03-14T05:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134699#M10565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your physical sort is really slow, setting up a sorted cursor is a much faster way to get the first-sorted record. Here's my suggested fix for this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Sort Dissolve selected lines&lt;/SPAN&gt;
sort &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"in_memory\Sort1"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Sort_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'Dissolve1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sort&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'Length DESCENDING;Angle ASCENDING;COUNT_Sorting ASCENDING'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'UR'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Select first record&lt;/SPAN&gt;
sort2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"in_memory\Sort2"&lt;/SPAN&gt;
sel &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Select_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sort&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sort2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'OID = 1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if the data are in a file geodatabase, you can use ORDER BY with a search cursor instead of a (slow) sort to find the first OID (sorted)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;xdis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Dissolve1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchGDB &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"/xdis"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
oid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;xdis&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ORDER BY Length DESC, ANGLE ASC, COUNT_Sorting ASC"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
sort2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Select_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;xdis&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'in_memory/sort2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
          &lt;SPAN class="string token"&gt;'OID = {}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;oid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:32:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134699#M10565</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T07:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134700#M10566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For the polygon class for instance,&amp;nbsp;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/classes/polygon.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/polygon.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Polygon—ArcPy classes | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can find the geometry functions like convex hull in there&lt;/P&gt;&lt;P&gt;similarly for length etc.&lt;/P&gt;&lt;P&gt;You can create arrays do quick calculations resulting in the equivalent of a field, then use arcpy.ExtendTable, which effectively, allows you to do vectorized calculations, and add the result to a table.&lt;/P&gt;&lt;P&gt;You can accomplish many tasks at once.&amp;nbsp; For example, you need the perimeter of a buffered polyline's convex hull.&lt;/P&gt;&lt;P&gt;Your worst case scenario, a 2 point polyline parallel to the x-axis&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;p0 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Point&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
p1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Point&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
poly &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Polyline&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Array&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;p0&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;p1&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
polybuff &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; poly&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;buffer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
ch &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; polybuff&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;convexHull&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
ch&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;length
Out&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;171&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;32.55081089915268&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;of course this doesn't have to be done line-by-line, but you read the geometry, buffer (line 4) do the convex hull (line 5), get its length and add it to a field.&amp;nbsp; That whole sequence can be a 'def' for use in the field calculator for example&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:32:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134700#M10566</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T07:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134701#M10567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I will look into this, it will take some time to get my head around this code &amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2019 06:10:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134701#M10567</guid>
      <dc:creator>AndrewNeedham1</dc:creator>
      <dc:date>2019-03-14T06:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134702#M10568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome thanks,&amp;nbsp;I haven't seen a&amp;nbsp;search cursor used&amp;nbsp;in that way before. I would assume the Dissolve FC could be used directly into the Search Cursor instead of using the Copy Features. Thus eliminating an extra step?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2019 06:21:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134702#M10568</guid>
      <dc:creator>AndrewNeedham1</dc:creator>
      <dc:date>2019-03-14T06:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to speedup the following code</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134703#M10569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;I would assume the Dissolve FC could be used directly into the Search Cursor instead of using the Copy Features. Thus eliminating an extra step?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I don't believe the ORDER BY will work using an in_memory feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2019 16:05:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-speedup-the-following-code/m-p/134703#M10569</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2019-03-14T16:05:51Z</dc:date>
    </item>
  </channel>
</rss>

