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

Christian Reis kiko@async.com.br
Tue, 11 Feb 2003 19:04:22 -0200


On Tue, Feb 11, 2003 at 03:24:05PM -0500, Shane Hathaway wrote:
> Casey Duncan wrote:
> > An alternative which is perhaps more palatable is to just set the whole 
> > mutable object into the btree again. Like:
> > 
> > l = tree['bar']
> > l.append(4)
> > tree['bar'] = l # Trigger list persistance
> 
> In fact, if you put simple lists in BTrees, you have to use this 
> pattern.  Setting tree._p_changed will not get the right object stored. 

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?

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"?

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL