MCPcopy Create free account
hub / github.com/cloudpipe/cloudpickle / save_function

Method save_function

cloudpickle/cloudpickle.py:1481–1494  ·  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

1479 dispatch[type] = save_global
1480
1481 def save_function(self, obj, name=None):
1482 """Registered with the dispatch to handle all function types.
1483
1484 Determines what kind of function obj is (e.g. lambda, defined at
1485 interactive prompt, etc) and handles the pickling appropriately.
1486 """
1487 if _should_pickle_by_reference(obj, name=name):
1488 return super().save_global(obj, name=name)
1489 elif PYPY and isinstance(obj.__code__, builtin_code_type):
1490 return self.save_pypy_builtin_func(obj)
1491 else:
1492 return self._save_reduce_pickle5(
1493 *self._dynamic_function_reduce(obj), obj=obj
1494 )
1495
1496 def save_pypy_builtin_func(self, obj):
1497 """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