<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
<br>
<blockquote
 cite="mid:AANLkTinkKkEmXmN0Ak2aat20A6hJBL9Yc1YCm=VjZ0DN@mail.gmail.com"
 type="cite">
  <pre wrap="">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.
  </pre>
</blockquote>
<br>
Makes total sense... actually:<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.zodb.org/documentation/guide/modules.html#total-ordering-and-persistence">http://www.zodb.org/documentation/guide/modules.html#total-ordering-and-persistence</a><br>
<br>
Seems to indicate that.<br>
<br>
<br>
Actually, i believe that what mislead me was:<br>
<br>
"
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<span class="Apple-style-span"
 style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span
 class="Apple-style-span"
 style="font-family: Verdana,Helvetica,Arial,sans-serif; font-size: 13px;">Prior
to this change, it was not safe to use Persistent objects as keys in a
BTree.</span></span>" (
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<a
 href="http://docs.zope.org/zope3/Code/ZODB/ConflictResolution.txt/index.html">http://docs.zope.org/zope3/Code/ZODB/ConflictResolution.txt/index.html</a>)<br>
<br>
<blockquote
 cite="mid:AANLkTinkKkEmXmN0Ak2aat20A6hJBL9Yc1YCm=VjZ0DN@mail.gmail.com"
 type="cite">
  <pre wrap="">I think implementing a stable hash function for your type could make
this work though.

  </pre>
</blockquote>
<br>
>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...<br>
<br>
Thanks a lot!<br>
<br>
Pedro<br>
<br>
<pre class="moz-signature" cols="72">-- 
José Pedro Ferreira

Indico Team

IT-UDS-AVC

513-R-0042
CERN, Geneva, Switzerland
</pre>
</body>
</html>