[issue41547] Expose default __getstate__ and __setstate__

2020-08-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This is virtually a duplicate of isssue26579.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Support pickling slots in subclasses of common classes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41547] Expose default __getstate__ and __setstate__

2020-08-13 Thread youkaichao

New submission from youkaichao :

According to the doc ( 
https://docs.python.org/3/library/pickle.html#object.__getstate__ ), an object 
may not have a __getstate__ method.

During pickling and unpickling, python first finds __getstate__ and 
__setstate__, which may invoke a customed __getattr__. I think this is 
unnecessary if python just provides a default implementation for __getstate__ / 
__setstate__ . An additional benefit of this is that __setstate__ and 
__getstate__ becomes available for every object and it is possible to do 
something like ``getstate(obj)``.

For people who customize __getattr__, I think no one intends to deal with 
``obj.__getattr__(“__getstate__”)``, so it makes sense not to invoke 
``__getattr__`` during pickling and unpickling.

--
messages: 375369
nosy: youkaichao
priority: normal
severity: normal
status: open
title: Expose default __getstate__ and __setstate__
type: behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com