<?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: Does creating a FeatureLayer speed up arcpy processing? Looks like it... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377826#M29790</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before you increased the number of points in your test data it's interesting to note that your run times are around 9 to 10 seconds. Mine were around the 20 second mark! I'm guessing this is down to you having a superior PC? The PC that I did the testing on was a 32 bit operating system with a Intel Core 2 CPU (2.4Ghz).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering after I posted if the performance benefit would be noticeable in a much more complex scenario? For example some cursor going through some dataset farming out selections for subsequent processing steps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also wonder if this make FeatureLayer "micro" boost in performance extends to TableViews and RasterLayers? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway it's good to have a naysayer casting doubt at every opportunity as I would never have queried such a technique.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Oct 2013 17:50:51 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2013-10-04T17:50:51Z</dc:date>
    <item>
      <title>Does creating a FeatureLayer speed up arcpy processing? Looks like it...</title>
      <link>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377824#M29788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In a recent thread discussed &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/93327-AddField-slow-even-in-in_memory-workspace" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt; it was suggested that creating a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN&gt; from a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;FeatureClass&lt;/SPAN&gt;&lt;SPAN&gt; can improve the performance of arcpy. It was clear from the subsequent discussions that this was not necessarily accepted by others and I was skeptical as I have never seen any reference to this "top tip".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So with time to kill I set out to test this and I am reporting my findings for others to mull over.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have 10.2 on a VISTA OS and a I ran everything in &lt;/SPAN&gt;&lt;A href="https://code.google.com/p/pyscripter/" rel="nofollow noopener noreferrer" target="_blank"&gt;Pyscripter&lt;/A&gt;&lt;SPAN&gt;. On each run I reset the python interpreter window and reset the source dataset so the conditions were the same. I had stopped all other applications and did not touch the keyboard whilst the code ran.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had created a point shapefile with 1000 random points, my test code simply added a field and then calculated a constant value into this new field. The code repeated these steps 49 times. I record the start and end times so I could work out how long it took. I repeated the test 10 times for each scenario. My null hypothesis is that there is no performance difference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The two test scenarios where:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Access the source dataset as a full path name, what you typically see in many examples in the ESRI help&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Create a FeatureLayer first and use that instead of the full path name&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;My code for accessing the full path was:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import time


print "START TIME = " + time.asctime()


&lt;SPAN style="color:#008000;"&gt;# Source dataset to update&lt;/SPAN&gt;
fc = r"C:\Scratch\TestLayer.shp"


&lt;SPAN style="color:#008000;"&gt;# Create a list of numbers from 1 to 50&lt;/SPAN&gt;
l = range(1,50,1)


for i in l:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Create a field name and add it to dataset&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; name = "F_" + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Processing "&amp;nbsp; + name
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(fc,name,"LONG")


&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Populate field with a constant 999&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(fc,name,"999","VB")


print "END TIME = " + time.asctime()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code for accessing a FeatureLayer was:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import time


print "START TIME = " + time.asctime()


&lt;SPAN style="color:#008000;"&gt;# Source dataset to update&lt;/SPAN&gt;
fc = r"C:\Scratch\TestLayer.shp"
fl = "TestLayer"
arcpy.MakeFeatureLayer_management(fc,fl)


&lt;SPAN style="color:#008000;"&gt;# Create a list of numbers from 1 to 50&lt;/SPAN&gt;
l = range(1,50,1)


for i in l:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Create a field name and add it to dataset&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; name = "F_" + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Processing "&amp;nbsp; + name
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(fl,name,"LONG")


&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Populate field with a constant 999&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(fl,name,"999","VB")


print "END TIME = " + time.asctime()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For the 10 test runs the mean time for running the code for:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;full path name was 22 seconds&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;FeatureLayer was 19.5 seconds&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;I did a Two-Sample T-Test in &lt;/SPAN&gt;&lt;A href="http://www.minitab.com/en-US/default.aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;Minitab&lt;/A&gt;&lt;SPAN&gt; which is significant which means I reject my null hypothesis.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:2;"&gt;&lt;SPAN style="font-family:courier new;"&gt;Two-sample T for fl vs fc&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp; N&amp;nbsp; Mean&amp;nbsp;&amp;nbsp; StDev&amp;nbsp; SE Mean&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;fl&amp;nbsp; 10&amp;nbsp; 19.500&amp;nbsp; 0.527&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.17&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;fc&amp;nbsp; 10&amp;nbsp; 22.000&amp;nbsp; 0.816&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.26&lt;/SPAN&gt;&lt;SPAN style="font-family:courier new;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;Difference = mu (fl) - mu (fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;Estimate for difference:&amp;nbsp; -2.500&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;95% CI for difference:&amp;nbsp; (-3.155, -1.845)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;T-Test of difference = 0 (vs not =): T-Value = -8.13&amp;nbsp; P-Value = 0.000&amp;nbsp; DF = 15&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;So for this simple scenario there was a significant difference in performance by creating a FeatureLayer first...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting hey?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:26:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377824#M29788</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-12-11T17:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Does creating a FeatureLayer speed up arcpy processing? Looks like it...</title>
      <link>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377825#M29789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay - since I was the naysayer....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan, I ran your code on my own point .shp (1000 random pnts). I ran each script 4 times, restarting Python for each run. Here are the results (in seconds):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Feature Layer: [9, 9, 9, 9]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Feature Class: [10, 9, 10, 9]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Okay.... 5% faster it seems from this limited test, enough of a (very small) difference to get me curiuous... so I upped the feature cound to 10,000 pnts... Here are the results of those (three this time) runs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Feature Layer: [49.08, 46.10, 46.36]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Feature Class: [51.06, 46.78, 45.51]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So about a 1% speed boost this time... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll stand by my prior statement on the other thread.... but I will admit the minutia of these results may indicate there is a very small performance gain by adding fields to a feature layer instead of the source featureclass. Because the overall speed boost difference was reduced (5% to 1%) by adding more records, I'm deducing that the performace gain is coming from the AddField tool, and not the CalcField tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Oct 2013 16:37:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377825#M29789</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-10-04T16:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Does creating a FeatureLayer speed up arcpy processing? Looks like it...</title>
      <link>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377826#M29790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before you increased the number of points in your test data it's interesting to note that your run times are around 9 to 10 seconds. Mine were around the 20 second mark! I'm guessing this is down to you having a superior PC? The PC that I did the testing on was a 32 bit operating system with a Intel Core 2 CPU (2.4Ghz).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering after I posted if the performance benefit would be noticeable in a much more complex scenario? For example some cursor going through some dataset farming out selections for subsequent processing steps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also wonder if this make FeatureLayer "micro" boost in performance extends to TableViews and RasterLayers? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway it's good to have a naysayer casting doubt at every opportunity as I would never have queried such a technique.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Oct 2013 17:50:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377826#M29790</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-10-04T17:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Does creating a FeatureLayer speed up arcpy processing? Looks like it...</title>
      <link>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377827#M29791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I ran that on my new machine: Xeon 2687 (3.1 Ghz w/ turbo @ 3.9Ghz) with 2 solid state drives in RAID0 - Also 64 GB of RAM and 64bit OS too, but really only the disk and processor makes a real difference for a test like this I think. Moore's Law and some other stuff (like SSDs!) seem to be in full effect still - and so these infernal machines seem to contuinue getting exponentially faster and faster every year. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Like Kevin was saying on the other thread, a feature layer is a pointer (a door if you will) to an on-disk feature class. So I can believe that they might increase performace for some thinks like adding fields, listing fields, etc. But I'm not convinced about the geometry stuff... So for example, unioning 50 featureclasses together vs. unioning 50 feature layers (of the feature classes). Maybe you would see a noticeable diff if they were really small and the schema stuff (and not the geometry&amp;nbsp; stuff) was the bulk of the processing? I'd have a hard time accepting a noticable boost for "geometrically large" datasets though. Have to test that out sometime in the near future!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could it be that many of the geoprocessing tools, behind the scenes, have to convert the featureclasses to layers, and that if they are already a layer, then this small added overhead is not needed... thus the (slighter) faster run times?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Oct 2013 20:09:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/does-creating-a-featurelayer-speed-up-arcpy/m-p/377827#M29791</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-10-04T20:09:51Z</dc:date>
    </item>
  </channel>
</rss>

