[ZODB-Dev] BTree sets and unhashable objects
Tim Peters
tim at zope.com
Wed Jun 18 15:01:11 EDT 2003
[Tim]
>> I don't know which Wiki that refers to (have a URL handy?), but it's
>> wrong: BTree operations (which include OOSets) never ask for an
>> object's hash code (Python dicts do, BTrees do not).
[Roché Compaan]
> http://www.zope.org/Members/ajung/BTrees/DataTypes
Thanks! I added comments to the page.
> Actually it doesn't say that sets can only work with hashable objects
> - I assumed that this was the problem because the wiki does say that
> OOBTrees maps hashable objects to hashable objects.
It's still wrong <wink>. Keys don't have to be hashable, but do need a
consistent total ordering; values don't have to be hashable or comparable.
...
>> The problem is due to something else.
> So this might be a bug?
Probably not in the BTree code, although that's possible. It's really not
possible to say more here now, since we haven't seen any part of your code.
>> The "real rules" for BTrees are here:
>>
>> http://www.zope.org/Wikis/ZODB/guide/node6.html
>>
>> esp. section 5.3.1, "Total Ordering and Persistence".
> I'll have a look tonight to see if I meet all the criteria - if I do
> then I will send some more info to determine if I've hit a bug or not.
The easiest way to get in trouble is to use instances of a user-defined
(app-defined) class, which class doesn't define a __cmp__ method.
More information about the ZODB-Dev
mailing list