diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-09 14:36:23 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-09 14:36:23 -0400 |
| commit | 9afe585f4599d8114abe8d11f924c206a8962cda (patch) | |
| tree | dd734140049a3f0e744f43791bdf18971f33bbe6 /lib/sqlalchemy/sql/visitors.py | |
| parent | fcfa62bd76ee0cdb125f0eb46ec4c1f625cbd6e7 (diff) | |
| download | sqlalchemy-9afe585f4599d8114abe8d11f924c206a8962cda.tar.gz | |
- pick around gaining modest dings in callcounts here and there
Diffstat (limited to 'lib/sqlalchemy/sql/visitors.py')
| -rw-r--r-- | lib/sqlalchemy/sql/visitors.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index d09b82148..b53b44eec 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -213,12 +213,19 @@ def iterate(obj, opts): traversal is configured to be breadth-first. """ + # fasttrack for atomic elements like columns + children = obj.get_children(**opts) + if not children: + return [obj] + + traversal = deque() stack = deque([obj]) while stack: t = stack.popleft() - yield t + traversal.append(t) for c in t.get_children(**opts): stack.append(c) + return iter(traversal) def iterate_depthfirst(obj, opts): @@ -227,6 +234,11 @@ def iterate_depthfirst(obj, opts): traversal is configured to be depth-first. """ + # fasttrack for atomic elements like columns + children = obj.get_children(**opts) + if not children: + return [obj] + stack = deque([obj]) traversal = deque() while stack: |
