Stackless pickling code for functions is incomplete
akruis opened this issue · 3 comments
Currently Stackless pickles the following attributes of functions: func_code
, func_globals
, func_name
, func_defaults
, func_closure
, func_module
.
It does not pickle the following attributes: func_kwdefaults
, func_doc
, func_dict
, func_annotations
, func_qualname
.
It also does not pickle func_weakreflist
, but that's OK.
We should either update the pickling code or remove the pickling code. That's possible, because functions can be pickled using pure Python. See https://github.com/cloudpipe/cloudpickle or https://pypi.org/project/sPickle/. Incidentally, the same also applies to pickling modules.
A quick experiment shows, that we better don't drop pickling support for functions or modules. Our test suite would fail miserably.
We did a pycon sprint back in 2012 or so, to add pickling of runtime structures to C python, so that generators, etc and various run-time state could be pickled. There wasn't a huge interest and some things were not accepted into the core...
I think it is worth it to try to retain this functionality if possible. Attributes get added from time to time and we simply have to be aware of them.
I added the missing attributes.