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:

http://www.zodb.org/documentation/guide/modules.html#total-ordering-and-persistence

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." ( http://docs.zope.org/zope3/Code/ZODB/ConflictResolution.txt/index.html)

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!

Pedro

--
José Pedro Ferreira

Indico Team

IT-UDS-AVC

513-R-0042
CERN, Geneva, Switzerland

_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to