[Zope] some Zope issues: dtml-zpt, permissions, scalability

Dieter Maurer dieter at handshake.de
Wed Nov 26 14:41:48 EST 2003


Michael Bernstein wrote at 2003-11-25 13:00 -0800:
 > ...
 > The most critical difference in using a BTree is that you cannot simply 
 > use assignment such as
 > 
 >    self.Entries[id] = entry

This is not true as you can see from this transcript.

linux: python
Python 2.1.3 (#2, Mar 13 2003, 13:39:51)
>>> from BTrees.OOBTree import OOBTree
>>> t=OOBTree()
>>> t[1]=2
>>> t[1]
2

"BTrees" behave much like dictionaries.
Essential differences are for the "keys", "values" and "items"
methods: unlike as for dictionaries their return values are
"life"; they change when the tree is changed.
This can lead to very strange effects, e.g. in code like

     for k in tree.keys():
         ...
	 tree[k] = ...
	 tree[l] = ...
	 del tree[m]

Use the "tuple(tree.keys())" idiom when you plan to modify the tree
while using the "keys()" result (same for friends, of course).

Another essential note: determining the length of a tree
(or "keys()" and friends) is expensive (linear in the length).


-- 
Dieter



More information about the Zope mailing list