SVN: Zope/trunk/src/OFS/Traversable.py Commit micro-optimization, tuple addition is faster for few elements

Hanno Schlichting <[email protected]>
Newsgroups gmane.comp.web.zope.cvs
Message-ID <[email protected]>
Log message for revision 122273:
  Commit micro-optimization, tuple addition is faster for few elements
  

Changed:
  U   Zope/trunk/src/OFS/Traversable.py

-=-
Modified: Zope/trunk/src/OFS/Traversable.py
===================================================================
--- Zope/trunk/src/OFS/Traversable.py	2011-07-17 18:53:15 UTC (rev 122272)
+++ Zope/trunk/src/OFS/Traversable.py	2011-07-17 19:29:41 UTC (rev 122273)
@@ -126,11 +126,11 @@
             if id is None:
                 id = self.getId()
 
+        path = (id, )
         p = aq_parent(aq_inner(self))
         if p is None:
-            return (id, )
+            return path
 
-        path = [id]
         func = self.getPhysicalPath.im_func
         while p is not None:
             if func is p.getPhysicalPath.im_func:
@@ -142,17 +142,16 @@
                     if pid is None:
                         pid = p.getId()
 
-                path.insert(0, pid)
+                path = (pid, ) + path
                 try:
                     p = p.__parent__
                 except AttributeError:
                     p = None
             else:
                 if IApplication.providedBy(p):
-                    path.insert(0, '')
-                    path = tuple(path)
+                    path = ('', ) + path
                 else:
-                    path = p.getPhysicalPath() + tuple(path)
+                    path = p.getPhysicalPath() + path
                 break
 
         return path

_______________________________________________
Zope-Checkins maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-checkins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.