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

Method _function_reduce

cloudpickle/cloudpickle.py:1264–1276  ·  view source on GitHub ↗

Reducer for function objects. If obj is a top-level attribute of a file-backed module, this reducer returns NotImplemented, making the cloudpickle.Pickler fall back to traditional pickle.Pickler routines to save obj. Otherwise, it reduces obj using a custom cloudpick

(self, obj)

Source from the content-addressed store, hash-verified

1262 return (_make_function, newargs, state, None, None, _function_setstate)
1263
1264 def _function_reduce(self, obj):
1265 """Reducer for function objects.
1266
1267 If obj is a top-level attribute of a file-backed module, this reducer
1268 returns NotImplemented, making the cloudpickle.Pickler fall back to
1269 traditional pickle.Pickler routines to save obj. Otherwise, it reduces
1270 obj using a custom cloudpickle reducer designed specifically to handle
1271 dynamic functions.
1272 """
1273 if _should_pickle_by_reference(obj):
1274 return NotImplemented
1275 else:
1276 return self._dynamic_function_reduce(obj)
1277
1278 def _function_getnewargs(self, func):
1279 code = func.__code__

Callers 1

reducer_overrideMethod · 0.95

Calls 2

Tested by

no test coverage detected