[Checkins] SVN: zope.index/trunk/ KeywordIndex: Minor optimization; use __nonzero__ instead of __len__

Shane Hathaway shane at hathawaymix.org
Sat Dec 3 23:56:03 UTC 2011


Log message for revision 123568:
  KeywordIndex: Minor optimization; use __nonzero__ instead of __len__
  to avoid loading the full TreeSet.
  

Changed:
  U   zope.index/trunk/CHANGES.txt
  U   zope.index/trunk/setup.py
  U   zope.index/trunk/src/zope/index/keyword/index.py

-=-
Modified: zope.index/trunk/CHANGES.txt
===================================================================
--- zope.index/trunk/CHANGES.txt	2011-12-03 23:34:19 UTC (rev 123567)
+++ zope.index/trunk/CHANGES.txt	2011-12-03 23:56:02 UTC (rev 123568)
@@ -1,6 +1,12 @@
 Changes
 =======
 
+3.6.3 (2011-12-03)
+------------------
+
+- KeywordIndex: Minor optimization; use __nonzero__ instead of __len__
+  to avoid loading the full TreeSet.
+
 3.6.2 (2011-12-03)
 ------------------
 

Modified: zope.index/trunk/setup.py
===================================================================
--- zope.index/trunk/setup.py	2011-12-03 23:34:19 UTC (rev 123567)
+++ zope.index/trunk/setup.py	2011-12-03 23:56:02 UTC (rev 123568)
@@ -61,7 +61,7 @@
         print >> sys.stderr, '*' * 80
 
 setup(name='zope.index',
-      version='3.6.2',
+      version='3.6.3',
       url='http://pypi.python.org/pypi/zope.index',
       license='ZPL 2.1',
       author='Zope Foundation and Contributors',

Modified: zope.index/trunk/src/zope/index/keyword/index.py
===================================================================
--- zope.index/trunk/src/zope/index/keyword/index.py	2011-12-03 23:34:19 UTC (rev 123567)
+++ zope.index/trunk/src/zope/index/keyword/index.py	2011-12-03 23:56:02 UTC (rev 123568)
@@ -97,7 +97,7 @@
             for word in kw_removed:
                 fwd = self._fwd_index[word]
                 fwd.remove(docid)
-                if len(fwd) == 0:
+                if not fwd:
                     del self._fwd_index[word]
 
             # now update reverse and forward indexes



More information about the checkins mailing list