[ZODB-Dev] Re: PersistentMapping

Thomas Lotze tl at gocept.com
Thu Nov 17 10:17:16 EST 2005


Jeremy Hylton wrote:

> It has been possible to inherit from dictionary since Python 2.2, but
> it is not possible for a persistent object and it would not do what
> you expect even if it were possible.  A persistent object has a custom
> C layout and so does dict, so it is not possible to have them both as
> base classes.  (TypeError: multiple bases have instance lay-out
> conflict.  (I don't know why there is a hypen in lay-out.))  If it
> were possible, it wouldn't work anyway.  If you inherit from dict and
> override its builtin methods, like __setitem__, your overridden method
> will be ignored by C code using methods like PyDict_SetItem().

Thanks for the explanation.

> On the other hand, I think that this omission is just an oversight. It
> would probably be a good idea to change PersistentDict/Mapping to use
> the DictMixin instead of UserDict.

I'd have to take a look at the mixin before I can come up with an educated
answer.

-- 
Thomas



More information about the ZODB-Dev mailing list