[Zope-Checkins] SVN: Zope/trunk/src/OFS/Traversable.py Commit micro-optimization, tuple addition is faster for few elements
Hanno Schlichting
hannosch at hannosch.eu
Sun Jul 17 15:29:41 EDT 2011
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
More information about the Zope-Checkins
mailing list