[ZODB-Dev] Decouple persistence, database, and cache

Jim Fulton jim at zope.com
Sat Oct 7 09:58:27 EDT 2006


Dmitry Vasiliev wrote:
> Jim Fulton wrote:
>> I've created a proposal:
>>
>>   http://www.zope.org/Wikis/ZODB/DecouplePersistenceDatabaseAndCache
>>
>> for simplifying and decoupling the persistence and cache architectures.
>> I've been thinking about this for quite some time.  In fact, the 
>> ability to subclass
>> weakref.ref objects that appeared in Python 2.4 anticipates this. :)
> 
> I like the proposal but I don't understand some details:
> 
>  - Why do you want to use '__setitem__' method instead of for example 
> 'notify'? Is it only for "make this go fast"?

Yes, as I mentioned in the proposal.

__setitem__ is an example of a "slot".  A special kind of method
that doesn't require method lookup.  This means that getting hold of
the method in C is very fast.  Like most slots, __setitem__ can be called
without constructing an an argument tuple, assuming that the implementation
in in C.  Finally, __setitem__ doesn't return an object, thus avoiding
even the need to INCREF and DECREF the return value.


>  - Why are such values selected for the state constants 

For backward compatibility.

> (persistent.GhostState = None, persistent.ChangedState = True, 
> persistent.SavedState = False, persistent.ReadState = False)?

These aren't the values given in the proposal.  The proposal
doesn't refer to the special values True and False, but to values with
true or false (small t and f) boolian values. For example, ChangedState
could be 1 (or 42) and SavedState could be 0, 0.0, '', () or any
other value with a boolean false value.

Thanks for the questions.  This is very much a rough draft proposal.
I'm aware of one problem.  I'm not going to say what it is in hopes
that, in looking for it, others will find problems I haven't spotted
yet.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the ZODB-Dev mailing list