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)
| 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__ |
no test coverage detected