[z3-checkins] r5839 - z3/sqlos/trunk/container
dreamcatcher at codespeak.net
dreamcatcher at codespeak.net
Sat Jul 31 18:24:14 MEST 2004
Author: dreamcatcher
Date: Sat Jul 31 18:24:13 2004
New Revision: 5839
Modified:
z3/sqlos/trunk/container/__init__.py
Log:
Another patch, to avoid undesired memory consumption.
Modified: z3/sqlos/trunk/container/__init__.py
==============================================================================
--- z3/sqlos/trunk/container/__init__.py (original)
+++ z3/sqlos/trunk/container/__init__.py Sat Jul 31 18:24:13 2004
@@ -82,7 +82,7 @@
""" Return a sequence-like object containing the names
associated with the objects that appear in the folder
"""
- return [k for k, v in self.items()]
+ for name, obj in self.items(): yield name
def __iter__(self):
return iter(self.keys())
@@ -91,20 +91,17 @@
""" Return a sequence-like object containing the objects that
appear in the folder.
"""
- return [v for k, v in self.items()]
+ for name, obj in self.items(): yield obj
def items(self):
"""Return a sequence-like object containing tuples of the form
(name, object) for the objects that appear in the folder.
"""
- items = []
for factoryName in self.allowedFactories():
factory = getFactory(factoryName)
- items.extend([('%s.%s' % (factoryName, p.id), p)
- for p in factory.select()])
- items = [(n, contained(obj, parent=self, name=n))
- for n, obj in items]
- return items
+ for obj in factory.select():
+ name = '%s.%s' % (factoryName, obj.id)
+ yield (name, contained(obj, parent=self, name=name))
def __getitem__(self, name):
"""Return the named object, or the value of the default
@@ -147,7 +144,9 @@
def __len__(self):
"""Return the number of objects in the folder."""
- return len(self.keys())
+ i = 0
+ for k in self.keys(): i += 1
+ return i
def __delitem__(self, name):
"""Delete the named object from the container.
More information about the z3-checkins
mailing list