Created
March 12, 2018 19:46
-
-
Save stdavis/8f8051a17567731dfce2fdf9dabb3e92 to your computer and use it in GitHub Desktop.
walk_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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