[ZODB-Dev] BTrees questions
Martijn Faassen
faassen@vet.uu.nl
Tue, 18 Dec 2001 02:45:43 +0100
Jeremy Hylton wrote:
> >>>>> "MF" == Martijn Faassen <faassen@vet.uu.nl> writes:
[snip]
> MF> What happens if I keep a BTree in-memory anyway? I mean, if I
> MF> just create a BTree as a local variable, does the entire
> MF> structure exist in memory then? And how efficient is this? :)
>
> A BTree is a persistent object and so are each of its buckets. If you
> have a large BTree and lookup a specific key, you'll only touch a very
> small number of nodes or buckets. So that's very memory efficient.
But what if I don't attach the BTree to anything else? Will it still
be persistent? I guess the same applies to any object inheriting from
Persistent, and I think they just stay in memory until they're attached
to anything.
[snip]
> If you can use one of the I BTrees (IO, OI, II), you'll save memory
> because the int part is stored directly in the BTree instead of using
> a PyObject * to a Python int object.
Right, I'm using those a lot.
Sets by the way seem to give me the same problem as Buckets; when I
try to access their keys they give me the same list assignment error.
Perhaps we should doublecheck whether sets and buckets should really not be
used; sets in particular seem useful and why are they exposed to Python
(and have documentation in Interfaces.py) at all if we're not supposed to
use them? Sets have their own single argument .insert() method and everything.
Sometimes I only care whether an item is there, and there's no associated
value, and sets seem to fit, except that they're either buggy or I'm
misusing them..
Regards,
Martijn