On Thu, May 5, 2011 at 6:27 PM, Alexandre Garel <alex.ga...@tarentis.com> wrote:
>> I'm assuming doing a general check for "old == new" is not safe, as it
>> might not be implemented correctly for all objects and doing the
>> comparison might be expensive.
> I know very few of ZODB internals but in Python "old == new" does not
> means "old is new"
Sure, but we aren't interested in object identity here. We want to
know if something close to "cPickle.dumps(old_data, 1) ==
cPickle.dumps(new_data, 1)", for which "old_data == new_data" is an
approximation, but likely not correct in all cases. Checking for
identity would only work for ints, interned strings a very few other
> I don't know the way ZODB retrieve a particular object exactly but I
> assume it does this using _p_oid. So for persistant classes you could
> check old._p_oid == new._p_oid. For string, int you can of course use
> old is new.
The _p_oid of the object stays the same, it's the data it represents
that might change.
For more information about ZODB, see the ZODB Wiki:
ZODB-Dev mailing list - ZODB-Dev@zope.org