Tim Peters wrote:
There is only one commit in the following, so I'll assume you intended a
second commit at the end:

yes, *sigh*, must engage brain...

a.someTime = DateTime()

Is `a` persistent?  I'm assuming that it is.


...wait/do stuff...
a.someTime = DateTime()

I'm assuming another


was intended here.


...have we just committed a pickle containing all of 'a'?...

If `a` is persistent, yes.

If not?

Does mixing persistence into DateTime make a difference here?

No.  Assuming `a` is persistent, you changed `a`, so `a`'s state gets
written out.  This really has nothing to do with DateTime.  It would be the
same answer had you done, e.g.,

    a.someTime = None


    a.someTime = "hi!"


    a.someTime = OOBTree()


*sigh* thought as much :-S

One part is different:  if DateTime is not persistent, then the pickle for
a's state includes the full state of a.someTime's DateTime attribute (and
this is true for any attribute of any non-persistent type).  But if DateTime
is persistent, then a.someTime is pickled as a distinct object, and the
state for `a` contains only a reference to that distinct pickle (and again
this is true for any attribute of any persistent type).  a's full state is
pickled regardless.  The difference is in whether a's full state embeds
a.someTime's state directly, or "points to" a distinct pickle for
a.someTime's state.

Ah, okay, so having DateTime sublcass Persistent would only really matter if a had _lots_ of DateTime attributes. Does this ever happen?

If the same DateTime object is referenced by many persistent objects, there
can be major storage efficiencies is making DateTime persistent, because the
"many other objects" can all point to the same pickle.  I don't know, but I
doubt that's a likely scenario for DateTime objects.

Indeed :-/ Oh well...


Simplistix - Content Management, Zope & Python Consulting
           - http://www.simplistix.co.uk
For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to