[ZODB-Dev] updating BTrees
Tim Peters
tim at zope.com
Fri Apr 25 15:26:44 EDT 2003
[Nicholas Henke]
> Are there any plans to update BTrees for the newer MappingType methods
> for Python2.2 -- aka iterators, 'for i in IOBTree' will access all of
> the keys ?
This is already the case in ZODB4. Also "i in IOBTree" is true iff
IOBTree.has_key(i) is true, .iter{keys,values,items} were added whenever
they made sense (e.g., TreeSet.itervalues() doesn't make sense, as TreeSets
don't have values), and so on. This also means that BTree-based data
structures can be passed to the large number of builtin functions that
accept (any) iterable objects in 2.2. My favorite bizarre example <wink>:
>>> from zodb.btrees.IOBTree import *
>>> s = IOSet([24, 45])
>>> s
IOSet([24, 45])
>>> x, y = s
>>> print x, y
24 45
>>>
There are no current plans to backport this work to ZODB3, which needs to
remain compatible with Python 2.1 (the new-in-2.2 iteration and __contains__
protocols didn't exist in 2.1). ZODB4 requires at least 2.2., so it made
easy sense to enhance the ZODB4 flavor of BTree.
More information about the ZODB-Dev
mailing list