[ZODB-Dev] BTrees and setdefault
    Victor Safronovich 
    vsafronovich at naumen.ru
       
    Sun Aug 28 04:13:08 EDT 2005
    
    
  
Hello zodb-dev,
[Tim Peters]
TP> Despite that the message I linked to above was written last October, there
TP> are still only about a dozen total uses of setdefault() in the Python core,
TP> and there are still many more lines of code in the core implementing the
TP> thing than there are lines of code using it.  I remain -0 on the idea (which
TP> means it's OK by me, I just prefer not to bother).  Jim's +1 wipes out any
TP> number of -0 votes ;-).
+1 for adding setdefault for BTrees.
the code below
        if not self._index.has_key(comp):
            self._index[comp] = IOBTree()
        if not self._index[comp].has_key(level):
            self._index[comp][level] = IITreeSet()
        self._index[comp][level].insert(id)
may change to
     
        comp = self._index.setdefault( comp, IOBTree() )
        level = comp.setdefault( level, IITreeSet() )
        level.insert( id )
which looks much better.
-- 
Best regards,
 Victor Safronovich
 NauMen.NauDoc.SoftwareDeveloper  http://www.naumen.ru
    
    
More information about the ZODB-Dev
mailing list