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

Method _function_reduce

cloudpickle/cloudpickle.py:1278–1290  ·  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

1276 return (_make_function, newargs, state, None, None, _function_setstate)
1277
1278 def _function_reduce(self, obj):
1279 """Reducer for function objects.
1280
1281 If obj is a top-level attribute of a file-backed module, this reducer
1282 returns NotImplemented, making the cloudpickle.Pickler fall back to
1283 traditional pickle.Pickler routines to save obj. Otherwise, it reduces
1284 obj using a custom cloudpickle reducer designed specifically to handle
1285 dynamic functions.
1286 """
1287 if _should_pickle_by_reference(obj):
1288 return NotImplemented
1289 else:
1290 return self._dynamic_function_reduce(obj)
1291
1292 def _function_getnewargs(self, func):
1293 code = func.__code__

Callers 1

reducer_overrideMethod · 0.95

Calls 2

Tested by

no test coverage detected