Commit a46be1ec authored by Casey Duncan's avatar Casey Duncan

Merge unindex speed optimization from branch

parent a2c624ea
...@@ -286,17 +286,11 @@ class BaseIndex(Persistent): ...@@ -286,17 +286,11 @@ class BaseIndex(Persistent):
def _del_wordinfo(self, wid, docid): def _del_wordinfo(self, wid, docid):
doc2score = self._wordinfo[wid] doc2score = self._wordinfo[wid]
del doc2score[docid] del doc2score[docid]
numdocs = len(doc2score) if doc2score:
if numdocs == 0: self._wordinfo[wid] = doc2score # not redundant: Persistency!
else:
del self._wordinfo[wid] del self._wordinfo[wid]
self.length.change(-1) self.length.change(-1)
return
if numdocs == self.DICT_CUTOFF:
new = {}
for k, v in doc2score.items():
new[k] = v
doc2score = new
self._wordinfo[wid] = doc2score # not redundant: Persistency!
def inverse_doc_frequency(term_count, num_items): def inverse_doc_frequency(term_count, num_items):
"""Return the inverse doc frequency for a term, """Return the inverse doc frequency for a term,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment