Commits

painyeph  committed 2cd5460

version 0.24 DeltaListEntry 改为输出 iterable

  • Participants
  • Parent commits 6741b87

Comments (0)

Files changed (1)

File immutabase.py

 # 120423: version 0.21 增加 DeltaListEntry
 # 120423: version 0.22 增加 LazyDeltaListEntry
 # 120424: version 0.23 SingleBlobStore 增加 buffer_size 参数
+# 120427: version 0.24 DeltaListEntry 改为输出 iterable
 
 
 """Immutabase - lightweight read-only key-value database.
 
     def load(self, pos=None):
         num, = struct.unpack('I', self.store.read(pos, False, 4))
-        value = []
         d = p = 0
         for c in self.store.read(None, False, num):
             c = ord(c)
             if c & 0x80:
                 p += d | (c & 0x7F)
-                value.append(p)
+                yield p
                 d = 0
             else:
                 d = (d | c) << 7
-        return value
 
     def serialize(self, value):
         data = []
     [1, 3, 5, 10, 1000, 10000, 10001]
     """
 
-    def __generator(self, pos):
+    def load(self, pos=None):
+        pos, = struct.unpack('I', self.store.read(pos, False, 4))
         d = p = 0
         for pos in xrange(pos + 4, pos + 4 + struct.unpack('I', self.store.read(pos, False, 4))[0]):
             c = ord(self.store.read(pos, False, 1))
             else:
                 d = (d | c) << 7
 
-    def load(self, pos=None):
-        pos, = struct.unpack('I', self.store.read(pos, False, 4))
-        return self.__generator(pos)
-
     def serialize(self, value):
         data = []
         p = 0