[ZODB-Dev] Corrupted OOTreeSet - strange behavior

Laurence Rowe l at lrowe.co.uk
Mon Jul 18 09:03:23 EDT 2011


On 18 July 2011 13:08, Pedro Ferreira <jose.pedro.ferreira at cern.ch> wrote:
>> TreeSets are essentially BTrees with only keys. This means that the
>> members of a TreeSet must have a stable ordering. I suspect that that
>> c's class does not define the comparison methods (such as __lt__)
>> which means under Python 2 it falls back to the default ordering based
>> on object id (Python 3 will raise a TypeError instead, avoiding this
>> problem.) With ZODB an object's Python id (the memory address of the
>> object) will change whenever it is reloaded, i.e. across restarts,
>> after invalidation or removal from the cache.
>
> Yes, I know that. But I have a __cmp__ function defined, based on an
> object property that never changes. That should be enough, no?

I think it should, but are you absolutely certain it never changes?
Does list(s) == sorted(list(s)) and does list(s) ==
list(OOTreeSet(s))?

Laurence


More information about the ZODB-Dev mailing list