[Zope-Checkins] CVS: Zope/lib/python/OFS - ObjectManager.py:1.159
Andreas Jung
andreas@andreas-jung.com
Mon, 6 Jan 2003 08:40:37 -0500
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv6074
Modified Files:
ObjectManager.py
Log Message:
replaced objectValues(), objectItems() and objectIds() implementations
using list comprehensions (20-30% speedup under Python 2.2).
=== Zope/lib/python/OFS/ObjectManager.py 1.158 => 1.159 ===
--- Zope/lib/python/OFS/ObjectManager.py:1.158 Wed Aug 14 17:42:56 2002
+++ Zope/lib/python/OFS/ObjectManager.py Mon Jan 6 08:40:34 2003
@@ -336,23 +336,21 @@
if ob['meta_type'] in spec:
set.append(ob['id'])
return set
- return map(lambda i: i['id'], self._objects)
+ return [ o['id'] for o in self._objects ]
+
def objectValues(self, spec=None):
# Returns a list of actual subobjects of the current object.
# If 'spec' is specified, returns only objects whose meta_type
# match 'spec'.
- return map(self._getOb, self.objectIds(spec))
+ return [ self._getOb(id) for id in self.objectIds(spec) ]
+
def objectItems(self, spec=None):
# Returns a list of (id, subobject) tuples of the current object.
# If 'spec' is specified, returns only objects whose meta_type match
# 'spec'
- r=[]
- a=r.append
- g=self._getOb
- for id in self.objectIds(spec): a((id, g(id)))
- return r
+ return [ (id, self._getOb(id)) for id in self.objectIds(spec) ]
def objectMap(self):
# Return a tuple of mappings containing subobject meta-data