[ZODB-Dev] odd KeyError in OOSets

Nicholas Henke henken at seas.upenn.edu
Tue Apr 22 14:53:50 EDT 2003


On Fri, 2003-04-18 at 19:41, Tim Peters wrote:
> 
> I'm tempted to agree that the docs are lacking here, but don't really know
> where I'd find any docs to begin with <0.9 wink>.

Hehe -- true:). BTW, __cmp__ fixed the problem. Thanks!

> 
> > I am confused why cmp returns 0 above ( shows a match ),
> 
> Because the object addresses were identical.
> 
> > but the OOSet does not like it.  Is it complaining because it can't find
> > the object, or what I am assuming what is happening, where the objects
> > are out of order on restore, and that makes OOSet really unhappy?
> 
> Sets store objects in sorted order (sorted according to __cmp__), and use
> binary search for lookups.  If the objects aren't actually in sorted order,
> binary search may or may not find any particular object you're looking for.
> For example, if we do a binary search for 5 in
> 
>    100. -6, 5, 1, -20

Ahhh... I knew sleeping through 'Algorithms' would bite me someday.
Thanks for the lowdown on how *Sets work, things make much more sense
now.

Cheers!
Nic
-- 
Nicholas Henke
Penguin Herder & Linux Cluster System Programmer
Liniac Project - Univ. of Pennsylvania




More information about the ZODB-Dev mailing list