Skip to content

Instantly share code, notes, and snippets.

@stdavis
Created March 12, 2018 19:46
Show Gist options
  • Select an option

  • Save stdavis/8f8051a17567731dfce2fdf9dabb3e92 to your computer and use it in GitHub Desktop.

Select an option

Save stdavis/8f8051a17567731dfce2fdf9dabb3e92 to your computer and use it in GitHub Desktop.
walk_test.py
import timeit
from os.path import abspath, dirname, join
import arcpy
current_directory = abspath(dirname(__file__))
sgid = join(current_directory, 'SGID10.sde')
def dowalk():
print('walking')
walk = arcpy.da.Walk(sgid, followlinks=True, datatype=['FeatureClass', 'Table'])
names = []
for dirpath, dirnames, filenames in walk:
names = names + filenames
print('walk: ' + str(len(names)))
def dolist():
print('listing')
arcpy.env.workspace = sgid
names = arcpy.ListFeatureClasses() + arcpy.ListTables()
print('list: ' + str(len(names)))
print(timeit.timeit('dowalk()', number=3, globals=globals()))
print(timeit.timeit('dolist()', number=3, globals=globals()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment