[Persistence-sig] "Straw Baby" Persistence API
Phillip J. Eby
pje@telecommunity.com
Mon, 22 Jul 2002 21:32:50 -0400
At 04:43 PM 7/22/02 -0400, Tim Peters wrote:
> > but not _p_state. The purpose of assignment to _p_changed is to mark an
> > object as changed. Assignment seems clear here. _p_changed is a
> > flag, normally false; when an object is changed, it is set to true.
> > Why would a method call be any clearer?
>
>Presumably so that interested parties could influence what happens when an
>object becomes "dirty"? Maybe update a distributed cache, who knows. I
>suspect Philip Eby was getting at something related with his plea to set
>_p_changed only after an object is an a sane state again after a change is
>complete.
Yes, that's precisely it. Updating a distributed cache would be another
example of a "write-through changes" situation.
>OTOH, method calls are a large overhead whem the mutation is simple; e.g.,
>if a persistent list has to call a changed() method every time someone does
>
> a[i] = 6
>
>that's a real drag on potential performance.
Right, which is why the existing self._p_changed = 1 thing isn't too bad as
long as the descriptor is in C, and only calls through to the DM when the
object transitions from up-to-date to "dirty". Of course, write-through
DM's will immediately reset the state to "up-to-date", but if they want to
get called on every change, that's the price they'll pay.