[ZODB-Dev] Default comparison considered harmful in BTrees.

Jim Fulton jim at zope.com
Wed Oct 27 17:06:29 EDT 2010


On Mon, Oct 25, 2010 at 5:51 PM, Jim Fulton <jim at zope.com> wrote:
> I'm inclined to treat the use of the comparison operator inherited
> from object in BTrees to be a bug.  I plan to fix this on the
> trunk.
>
> I'm tempted to fix this in 10.1.  This change would make it impossible
> to add keys to BTrees or buckets or to add items to BTree-based
> sets if the key or items inherits it's comparison from object.  This
> would only apply to instances of new-style classes, including
> persistent objects. (It wouldn't affect old-style-class instances,
> which are too hard to introspect.)

Of course, it also wouldn't protect anybody from objects with
broken comparisons or objects that base reasonably sane comparison
on comparison of sub objects with bad comparison, such as:

  (object(), )

:)

I do think it would catch a common class of bug involving using
objects as keys.

Jim


-- 
Jim Fulton


More information about the ZODB-Dev mailing list