How to pickle a python function with its dependencies?

前端 未结 5 1117
我寻月下人不归
我寻月下人不归 2020-12-02 20:55

As a follow up to this question: Is there an easy way to pickle a python function (or otherwise serialize its code)?

I would like to see an example of this bullet fr

5条回答
  •  攒了一身酷
    2020-12-02 21:51

    Dill (along with other pickle variants, cloudpickle, etc.) seem to work when the function(s) being pickled are in the main module along with the pickling. If you are pickling a function from another module, that module name has to be present when the unpickling happens. I cannot seem to find a way around this limitation.

提交回复
热议问题