[ZODB-Dev] PersistentMapping good for large numbers of objects?

Tim Peters tim at zope.com
Tue Jul 22 16:46:23 EDT 2003


[Steve Alexander]
> For this case, I'd suggest writing a Python wrapper or subclass for
> xxBTree, and have that also manage the Length object. It would present
> the same interface as a BTree, but would route __len__ to the Length
> object, and keep the Length object updated on __setitem__,
> __delitem__, etc.
>
> Perhaps such a Python class would be a useful addition to the BTrees
> package?

Someone who wants it enough is welcome to write it.  I'm not sure it comes
up often enough to be worth the bother.  Sticking Python methods around all
mutating BTree methods would be delicate and incur a relatively huge speed
hit.  Methods like .update() would have to be faked via a Python loop,
calling __setitem__ one at a time, else you'd have no hope of distinguishing
(key, value) pairs with a new key from those replacing the value associated
with an existing key (the former case should increase the length by 1, the
latter is neutral).  It seems that most *apps* have natural places where a
Length object *should* be updated; they may forget to update it, or update
it inappropriately, or update it when it shouldn't be updated ... but apart
from those minor problems <wink>, they've got the only real shot at updating
it efficiently.




More information about the ZODB-Dev mailing list