Christian Heimes <[EMAIL PROTECTED]> added the comment:
Alexandre Vassalotti wrote:
> Alexandre Vassalotti <[EMAIL PROTECTED]> added the comment:
>
> Could explain me how this feature could be used, other than for
> providing the efficient and backward-compatible pickling mechanism for
> new-style classes?
The feature makes it easy to write __reduce__ methods for subclasses of
builtins. Take this example:
def __newobj__(cls, *args):
return cls.__new__(cls, *args)
class mydict(dict):
def __reduce__(self):
state = (dict(self), self.__dict__)
return (__newobj__, (self.__class__,), state)
Without the __reduce__ method the information in __dict__ and the class
would be lost.
Christian
_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3816>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com