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

Function _dynamic_class_reduce

cloudpickle/cloudpickle.py:1056–1080  ·  view source on GitHub ↗

Save a class that can't be referenced as a module attribute. This method is used to serialize classes that are defined inside functions, or that otherwise can't be serialized as attribute lookups from importable modules.

(obj)

Source from the content-addressed store, hash-verified

1054
1055
1056def _dynamic_class_reduce(obj):
1057 """Save a class that can't be referenced as a module attribute.
1058
1059 This method is used to serialize classes that are defined inside
1060 functions, or that otherwise can't be serialized as attribute lookups
1061 from importable modules.
1062 """
1063 if Enum is not None and issubclass(obj, Enum):
1064 return (
1065 _make_skeleton_enum,
1066 _enum_getnewargs(obj),
1067 _enum_getstate(obj),
1068 None,
1069 None,
1070 _class_setstate,
1071 )
1072 else:
1073 return (
1074 _make_skeleton_class,
1075 _class_getnewargs(obj),
1076 _class_getstate(obj),
1077 None,
1078 None,
1079 _class_setstate,
1080 )
1081
1082
1083def _class_reduce(obj):

Callers 2

_class_reduceFunction · 0.85
save_globalMethod · 0.85

Calls 4

_enum_getnewargsFunction · 0.85
_enum_getstateFunction · 0.85
_class_getnewargsFunction · 0.85
_class_getstateFunction · 0.85

Tested by

no test coverage detected