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)
| 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. |
nothing calls this directly
no test coverage detected