[ZODB-Dev] BTrees and Mutables, was Re: [IndexedCatalog] bug in default indexing

Jeremy Hylton jeremy@zope.com
11 Feb 2003 16:19:14 -0500


On Tue, 2003-02-11 at 16:04, Christian Reis wrote:

> Whoa. You mean to say that:
> 
>     l = tree['bar']
>     l.append(4)
>     tree['bar'] = l
> 
> is *not* the same as:
> 
>     tree['bar'].append(4)
> 
> right? And the first form *does* work as expected, or are there
> side-effects?

Yes.  Assignment on a container can cause side-effects.  That's
generally true, although it's probably unique to zodb that assignment
the same object changes the state of the container.

> This *really* should be documented on the BTrees page - I've never heard
> it mentioned and it is biting us badly inside IC (since we can't use
> Persistent* for performance reasons). Can anybody offer a bit of
> explanation as to why so I can put up on the page a reasonable
> explanation beyond "don do dat"?

There's nothing BTrees specific about it.  Whenever you modify a
non-persistent subobject and want the changer to persist, you most mark
as changed the persistent object that refers to it.  In a BTree the only
clear way to do that is by assignment.  I guess that could be mentioned
on the BTrees page.

Jeremy