[Python-ideas] Put default setstate and getstate on object for use in coöperative inheritance.

Nick Coghlan ncoghlan at gmail.com
Sun Jun 8 00:57:02 CEST 2014


On 8 Jun 2014 05:26, "Neil Girdhar" <mistersheik at gmail.com> wrote:
>
> In cooperative inheritance, the general pattern is to call super and do
whatever is particular to your class around that.  I needed to inherit from
the mixin I displayed at the top of this message in order to provide a
default setstate and getstate as these are not present in object.
 Intuitively, I think that it would be better for these to exist on object.
 I don't think I should have to provide these methods using a mixin.

You haven't explained why you're trying to do cooperative multiple
inheritance without a common base class to define the rules for your type
system. Leaving that element out of a cooperative multiple inheritance
design is generally a really bad idea.

>It's not a big deal, but I think it's a small wrinkle in Python not to
have default implementations of these methods given that that default
behavior is being done anyway.  Are there any drawbacks to providing these
default methods?

Yes - increased complexity in the language core. Currently, pickling is
completely independent of the language core, so implementations can reuse
the same pickling library (although they may want to write an accelerated
version eventually).

Cheers,
Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140608/33c948fa/attachment.html>


More information about the Python-ideas mailing list