def __reduce_ex__(self, protocol): header, frames = self.host_serialize() if protocol >= 5: frames = [pickle.PickleBuffer(f) for f in frames] else: frames = [numpy.asarray(f) for f in frames] return self.host_deserialize, (header, frames)
def test_issue_227_2(): q = array.array('Q', [1, 2, 3, 4, 5]) c = lz4.frame.compress(q) d = lz4.frame.LZ4FrameDecompressor().decompress(pickle.PickleBuffer(c)) assert memoryview(q).tobytes() == d
def __reduce_ex__(self, protocol): if protocol >= 5: return MemoryviewHolder, (pickle.PickleBuffer(self.mv),) else: return MemoryviewHolder, (self.mv.tobytes(),)
def __reduce_ex__(self, protocol): data = self.to_output('numpy') if protocol >= 5: data = pickle.PickleBuffer(data) return self.__class__, (data,)