[Zope-dev] Document

Matthew T. Kromer matt@digicool.com
Tue, 13 Jun 2000 14:20:31 -0400


"R. David Murray" wrote:
> 
> On Mon, 12 Jun 2000 howardchang@263.net wrote:
> > who can tell me where i can get documents or descriptions about Btree,Intset,IOBtree,OIBtree module
> 
> I suspect that the only documentation that you are going to
> find is the source code <wry grin>.

I can probably answer specific questions; I'm monkeying with an varation
that should play better in larger environments.  BTree is a broad tree
similar to a real B-tree (but it isn't height balanced and the nodes
aren't fixed size).  It can get compiled and built as a couple of
variants optimized for holding integer keys or values as opposed to the
generic object key and object value.

The common use might be to [untested]:

import ZODB
import BTree
import random

bt = BTree.BTree()
for i in range(0,100000):
	r = random.randint(0,100000)
	bt[r] = i

print "Items 5000-5100"
print list(bt.items(5000,5100))

Since this example uses integer keys and integer values the BTree form
is overkill, since it's storing integer Objects rather than just the
integers in the tree.

The BTrees play with the persistence engine and form the foundation of
most of the cataloging type operations in Zope; since you could, for
example, store a BTree with each index key being a keyword and each
value being a list of objects containing that keyword.