Use deque instead of simple list
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 13 Oct 2016 12:54:26 +0200
changeset 1895 1d3ccf2d7108
parent 1894 bd2e39dc44b8
child 1896 46987d1729b3
Use deque instead of simple list because I feel good that way. For better argumentation, see http://stackoverflow.com/questions/32543608/deque-popleft-and-list-pop0-is-there-performance-difference#32543726
xsd.py
--- a/xsd.py	Thu Oct 20 00:12:21 2016 +0200
+++ b/xsd.py	Thu Oct 13 12:54:26 2016 +0200
@@ -24,7 +24,7 @@
 
 import os.path as osp
 import re
-from collections import defaultdict
+from collections import defaultdict, deque
 
 from pyxst.xml_struct import build_xml_structure_from_schema, graph_nodes
 
@@ -405,7 +405,7 @@
     definitions will miss information that will be filed later).
     """
     _processed = set()
-    _stack = []
+    _stack = deque()
 
     def _push(xselement, etype, child_defs=None):
         if xselement not in _processed:
@@ -414,7 +414,7 @@
 
     _push(xselement, etype_name(xselement))
     while _stack:
-        parent, parent_etype, child_defs = _stack.pop(0)
+        parent, parent_etype, child_defs = _stack.popleft()
         if child_defs is None:
             child_defs = []
             skip = False