MCPcopy
hub / github.com/marimo-team/marimo / reducer_override

Method reducer_override

marimo/_save/encode.py:161–172  ·  view source on GitHub ↗
(self, obj: Any)

Source from the content-addressed store, hash-verified

159
160 class _ContentHashPickler(pickle.Pickler):
161 def reducer_override(self, obj: Any) -> Any:
162 if stub := maybe_get_custom_stub(obj):
163 return (bytes, (stub.to_bytes(),))
164 try:
165 if not is_primitive(obj) and is_data_primitive(obj):
166 h = hashlib.new(hash_type, usedforsecurity=False)
167 h.update(_contiguous_tensor_bytes(obj))
168 return (bytes, (h.digest(),))
169 except Exception:
170 pass
171 # Falls back to parent pickle
172 return NotImplemented
173
174 buf = io.BytesIO()
175 _ContentHashPickler(buf).dump(obj)

Callers

nothing calls this directly

Calls 7

maybe_get_custom_stubFunction · 0.90
is_primitiveFunction · 0.90
is_data_primitiveFunction · 0.90
_contiguous_tensor_bytesFunction · 0.85
newMethod · 0.80
updateMethod · 0.65
to_bytesMethod · 0.45

Tested by

no test coverage detected