FW: [ZODB-Dev] RE: B-Tree API - again!

Gfeller Martin Martin.Gfeller@comit.ch
Fri, 6 Dec 2002 18:35:05 +0100


-----Original Message-----
From: Christian Reis [mailto:kiko@async.com.br]=20
Sent: Friday, 06 Dec 2002 18:20
To: Gfeller Martin
Subject: Re: [ZODB-Dev] RE: B-Tree API - again!


On Fri, Dec 06, 2002 at 05:34:51PM +0100, Gfeller Martin wrote:
> Same effect: OOBTree.__delitem__ is not defined.=20

Now *that* might be a bug. If you look at Interfaces.py, you will see
it's said to be defined in IMinimalDictionary, which is what OOBTree
implements. However, a grep for delitem doesn't show it anywhere in the
actual code. Hmmm. But wait a minute.=20

It seems that del x[0] (where x is an OOBTree) is implemented in
setitem -- at least that's what PyObject_DelItem is calling here:

(gdb) where
#0  BTree_setitem (self=3D0x81f7450, key=3D0x81b4ce0, v=3D0x0) at
BTrees/BTreeTemplate.c:801
#1  0x80a996b in PyObject_DelItem (o=3D0x81f7450, key=3D0x81b4ce0)
at Objects/abstract.c:152

It seems to be setting NULL as the value for the specified key. Quite
neat. Now I wonder how you could go about implementing this in Python...
anyway, a very simple way to fix this could be implemented in
BTreeTemplate.c:

    static int
    BTree_delitem(BTree *self, PyObject *key):
    {
        if (_BTree_set(self, key, NULL, 0, 0) < 0) return -1;
        return 0;
    }

And maybe add it to the BTree_as_mapping struct. What do the ZODB ninjas
say?

De nada,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL