[ZODB-Dev] How to avoid shooting my foot

Guido van Rossum guido@python.org
Mon, 07 Oct 2002 07:46:11 -0400


> In ZODB it is necessary to manually mark modified 
> objects when objects attributes are modfied in place 
> (e.g. lists and dicts).
> 
> Q1: Is this a "real world" problem that bites people
> in the buttocks?

I am a relatively inexperienced Zope/ZODB application developer (even
though I'm now maintaining some of the underlying infrastructure :-).

When PythonLabs developed the new ZCTextIndex I was bit by this.  We
had a BTree attribute somewhere and we realized that it was often a
very small mapping and that a dict would be more efficient, so I
changed it into a dict for very small sizes.  But I wasn't aware of
this problem at all, and didn't change all the code that said

    self.mapping[k] = v

> Q2: Is it usually easy to figure out when it happens,
> or is the problem difficult to track?  (If the latter,
> any war stories would be appreciated.)

We had unit tests that captured the problem pretty quickly.  But since
I didn't know about this problem, it took me a while to figure out
what caused the problem.  I don't recall how much time it took me,
perhaps an hour or two at most.

Like the other examples you mentioned, it's one of those mistakes you
make exactly once.  And you have already been warned.

--Guido van Rossum (home page: http://www.python.org/~guido/)