[ZODB-Dev] PersistentMapping good for large numbers of objects?
Shane Hathaway
shane at zope.com
Tue Jul 22 18:01:52 EDT 2003
Steve Alexander wrote:
> Another approach would be for BTrees to grow a callback for whenever a
> new key is added and callback for whenever a new key is removed. Let's
> not go there :-)
>
> Yet another approach would be for BTrees to have a non-persistent
> settable integer counter, and they could increment and decrement the
> counter as keys are added or removed. A client could check this counter
> to see how an independently stored length is supposed to be changed.
>
> Here's what the method from the wrapper would look like:
>
> def update(self, seq):
> btree = self.__btree
> btree.deltaLength = 0
> btree.update(seq)
> if btree.deltaLength:
> self.__length += btree.deltaLength
>
>
> I'm not suggesting anyone implement this, just offering up ideas.
How about a combination of the above suggestions: every operation that
mutates a BTree could look for an attribute of the BTree called
"length". If it's there, the mutating operation could call
length.changed(deltaLength). Also, the __len__ slot could delegate to
the length object. That way, we don't have to wrap the BTree just to
get a minor (but nice) feature.
Shane
More information about the ZODB-Dev
mailing list