PyObject_Compare to compare different keys. Persistent doesn't
implement any special compare function and falls back to the standard
hash algorithm for an object. This happens to be its memory address.
The memory address obviously changes over time and the same address
gets reused for different objects.

Makes total sense... actually:

Seems to indicate that.

Actually, i believe that what mislead me was:

" Prior to this change, it was not safe to use Persistent objects as keys in a BTree." (

I think implementing a stable hash function for your type could make
this work though.

From what I read, ZODB doesn't use hash functions, relying on __cmp__ instead. So, I guess I should make my class non-persistent and implement a __cmp__ function for it...

Thanks a lot!


José Pedro Ferreira

Indico Team


CERN, Geneva, Switzerland

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -

Reply via email to