MCPcopy
hub / github.com/cloudpipe/cloudpickle / save_function

Method save_function

cloudpickle/cloudpickle.py:1467–1480  ·  view source on GitHub ↗

Registered with the dispatch to handle all function types. Determines what kind of function obj is (e.g. lambda, defined at interactive prompt, etc) and handles the pickling appropriately.

(self, obj, name=None)

Source from the content-addressed store, hash-verified

1465 dispatch[type] = save_global
1466
1467 def save_function(self, obj, name=None):
1468 """Registered with the dispatch to handle all function types.
1469
1470 Determines what kind of function obj is (e.g. lambda, defined at
1471 interactive prompt, etc) and handles the pickling appropriately.
1472 """
1473 if _should_pickle_by_reference(obj, name=name):
1474 return super().save_global(obj, name=name)
1475 elif PYPY and isinstance(obj.__code__, builtin_code_type):
1476 return self.save_pypy_builtin_func(obj)
1477 else:
1478 return self._save_reduce_pickle5(
1479 *self._dynamic_function_reduce(obj), obj=obj
1480 )
1481
1482 def save_pypy_builtin_func(self, obj):
1483 """Save pypy equivalent of builtin functions.

Callers

nothing calls this directly

Calls 5

_save_reduce_pickle5Method · 0.95
save_globalMethod · 0.80

Tested by

no test coverage detected