Log message for revision 118896:
  avoid pre-allocating the entire sequence, which adds unnecessary overhead in 
most cases.  instead use a dictionary to remember the already mapped sequence 
items.

Changed:
  U   Zope/branches/2.13/src/Products/ZCatalog/Lazy.py

-=-
Modified: Zope/branches/2.13/src/Products/ZCatalog/Lazy.py
===================================================================
--- Zope/branches/2.13/src/Products/ZCatalog/Lazy.py    2010-12-15 07:38:21 UTC 
(rev 118895)
+++ Zope/branches/2.13/src/Products/ZCatalog/Lazy.py    2010-12-15 07:38:29 UTC 
(rev 118896)
@@ -146,24 +146,18 @@
 
     def __init__(self, func, seq, length=None):
         self._seq = seq
+        self._data = {}
         self._func = func
         if length is not None:
             self._len = length
         else:
             self._len = len(seq)
-        self._marker = object()
-        self._data = [self._marker] * self._len
 
     def __getitem__(self, index):
         data = self._data
-        try:
-            s = self._seq
-        except AttributeError:
+        if index in data:
             return data[index]
-
-        value = data[index]
-        if value is self._marker:
-            value = data[index] = self._func(s[index])
+        value = data[index] = self._func(self._seq[index])
         return value
 
 

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to