Commits

Matt Chaput  committed d47b377

Added base methods to NumberEncoding in util.numlists.
Added timing() context manager to util.testing.
Fixed prefix encoding in util.text.

  • Participants
  • Parent commits c59a4a3

Comments (0)

Files changed (2)

File src/whoosh/util/numlists.py

 # Number list encoding base class
 
 class NumberEncoding(object):
+    maxint = None
+
+    def write_nums(self, f, numbers):
+        raise NotImplementedError
+
+    def read_nums(self, f, n):
+        raise NotImplementedError
+
     def write_deltas(self, f, numbers):
-        return self.write_nums(f, delta_encode(numbers))
+        return self.write_nums(f, list(delta_encode(numbers)))
 
     def read_deltas(self, f, n):
         return delta_decode(self.read_nums(f, n))
 # Fixed width encodings
 
 class FixedEncoding(NumberEncoding):
+    _encode = None
+    _decode = None
+    size = None
+
     def write_nums(self, f, numbers):
         _encode = self._encode
 

File src/whoosh/util/testing.py

 # policies, either expressed or implied, of Matt Chaput.
 
 import os.path, random, shutil, sys, tempfile, traceback
-from functools import wraps
+from contextlib import contextmanager
 
 from whoosh.filedb.filestore import FileStorage
 from whoosh.util import now
             if is_abstract_method(oattr):
                 raise Exception("%s.%s not overridden"
                                 % (subclass.__name__, attrname))
+
+
+@contextmanager
+def timing(name=None):
+    t = now()
+    yield
+    t = now() - t
+    print "%s: %0.06f s" % (name or '', t)