[Zope-dev] BTrees and Persistance
Yair Benita
y.benita at wanadoo.nl
Wed Jun 1 04:36:58 EDT 2005
I recently started to use ZODB and python as my chosen database
solution.
I am having a few problems with retaining changes in BTrees. I have
read the documentation and am aware of the _p_changed attribute. Still,
here is what I observe:
############################
# consider this simplified example
# lets ignore the open database method for now.
T = OOBTree()
# my trees contain integers as keys and sets as values
T.update({1:set([1,2,3]), 2:set([5,6,7])})
# I would really really like this to work
T[1].add(6)
T._p_changed = True
get_transaction().commit()
# but it doesn't.
# changes are not saved when I close the database and reopen it
# This works:
T[1].add(6)
T.update({1:T[1]})
############################
The thing is my sets tend to be very big and I am not sure but I think
that using T.update({1:T[1]}) will slow me down since a dictionary is
first created with a copy of the set which is very big and then the
OOBTree is updated. Or am I wrong here?
Can anyone suggest an efficient way that will not require a copy of the
set already stored in T[1]?
Thanks for the help,
Yair
More information about the Zope-Dev
mailing list