On 11/17/05, Thomas Lotze <[EMAIL PROTECTED]> wrote: > Hi, > > I just noticed two things about persistent.PersistentMapping: > > - It inherits from UserDict.UserDict. Is there any reason not to inherit > from dict directly, given that this has been possible since Python 2.3 > IIRC?
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(). > - Not all methods of the mapping interface are handled. In particular, > there's no reason not to handle pop() as popitems() is handled. > Unhandled methods that change the content of the dict lead to especially > nasty bugs as they seem to work OK during a transaction while their > effect is not permanent. 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. Jeremy _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev