[issue35900] Add pickler hook for the user to customize the serialization of user defined functions and types.

Pierre Glaser report at bugs.python.org
Mon Mar 11 10:51:39 EDT 2019


Pierre Glaser <pierreglaser at msn.com> added the comment:

Update:

Instead of changing permission on some attributes of function objects (__globals__ and __closure__), we added an optional argument called state_setter to save_reduce. This expects a callable that will be saved inside the object's pickle string, and called when setting the state of the object instead of using the default way in load_build.
This allows for external flexibility when setting custom pickling behavior of built-in types (in our use-cases: function and classes). I updated the patches so that anyone interested can take a look.

Also, we tested the cloudpickle package against these patches (see https://github.com/cloudpipe/cloudpickle/pull/253). The tests run fine, and we observe a 10-30x speedup for real-life use-cases. We are starting to hit convergence on the implementation :)

----------
Added file: https://bugs.python.org/file48203/pickler_hook.patch

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35900>
_______________________________________


More information about the Python-bugs-list mailing list