[ZODB-Dev] the difference between normal class object and the ZODB Persistent subclass object

Jim Fulton jim at zope.com
Tue Sep 27 05:47:42 EST 2011


On Tue, Sep 27, 2011 at 6:16 AM, 刘一新 <liuyxpp at gmail.com> wrote:
> Hi. I Use eye to browse the ZODB database. There, the methods of the float
> object or any normal class objects are also shown. Are these methods stored
> in the database?

Generally speaking, clases and methods are not stored in the database,
only class names. (It's possible to store special class
implementations in the database, but this is extremely advanced and
never done.

> Besides doing the _p_change magic, is there any extra advantage to write
> class derived from persistent.Persistent? Does ZODB store the
> persistent.Persistent subclass object more efficiently (much faster? smaller
> size?)

Persistent objects must derive from Persistent. Objects that don't
subclass Persistent:

- Do not get their own database records.

- Are stored by value, rather than by reference. So if, in your
  application, two persistet objects refer to the same non-persistent
  object, after being stored and reloaded, they non-persistent object
  will be duplicated and unshared.


Jim

--
Jim Fulton
http://www.linkedin.com/in/jimfulton


More information about the ZODB-Dev mailing list