MCPcopy Index your code
hub / github.com/RustPython/RustPython / __reduce_ex__

Method __reduce_ex__

Lib/test/pickletester.py:305–322  ·  view source on GitHub ↗
(self, protocol)

Source from the content-addressed store, hash-verified

303 f"bytes={self.array.tobytes()})")
304
305 def __reduce_ex__(self, protocol):
306 if not self.array.contiguous:
307 raise NotImplementedError("Reconstructing a non-contiguous "
308 "ndarray does not seem possible")
309 ndarray_kwargs = {"shape": self.array.shape,
310 "strides": self.array.strides,
311 "format": self.array.format,
312 "flags": (0 if self.readonly
313 else _testbuffer.ND_WRITABLE)}
314 pb = pickle.PickleBuffer(self.array)
315 if protocol >= 5:
316 return (type(self)._reconstruct,
317 (pb, ndarray_kwargs))
318 else:
319 # Need to serialize the bytes in physical order
320 with pb.raw() as m:
321 return (type(self)._reconstruct,
322 (m.tobytes(), ndarray_kwargs))
323
324 @classmethod
325 def _reconstruct(cls, obj, kwargs):

Callers

nothing calls this directly

Calls 2

rawMethod · 0.45
tobytesMethod · 0.45

Tested by

no test coverage detected