[Dev] Re: Data outside the box
Jeremy Hylton
jeremy at zope.com
Sun Nov 24 10:07:32 PST 2002
On Sun, 24 Nov 2002 02:09:20 -0800
David McCusker <david at osafoundation.org> wrote:
> patrickdlogan at attbi.com wrote:
> >Unfortunately btrees need reorganizing and they have
> measurable
> >overhead per datum. Also their code gets fairly complex
> when you
> >include deletes. They're also awkward to work with in
> chunks because
> >of their tree shape.
>
> I'll reply more to your entire email later, but night I
> wrote a long
> piece in my weblog in response to just the last sentence,
> about working
> with chunks of btrees:
>
>
http://www.treedragon.com/ged/map/ti/newNov02.htm#23nov02-dicts-as-arrays
A ZODB BTreee is iterable. If you call keys() or values()
or items() on the BTree, you'll get a BTreeItems object
back. The BTree items is a sequence type representing a
slice of the BTree without materializing the slice as a
copy. The methods that return BTreeItems objects typically
take optional arguments to specify min and max of a range.
In ZODB4 the BTrees and related objects also expose
Python-2.2 style iterators. So "for key in btree:" works
as expected and does "if key in btree:".
Jeremy
More information about the Dev
mailing list