MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / save_picklebuffer

Method save_picklebuffer

tools/python-3.11.9-amd64/Lib/pickle.py:825–847  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

823
824 if _HAVE_PICKLE_BUFFER:
825 def save_picklebuffer(self, obj):
826 if self.proto < 5:
827 raise PicklingError("PickleBuffer can only pickled with "
828 "protocol >= 5")
829 with obj.raw() as m:
830 if not m.contiguous:
831 raise PicklingError("PickleBuffer can not be pickled when "
832 "pointing to a non-contiguous buffer")
833 in_band = True
834 if self._buffer_callback is not None:
835 in_band = bool(self._buffer_callback(obj))
836 if in_band:
837 # Write data in-band
838 # XXX The C implementation avoids a copy here
839 if m.readonly:
840 self.save_bytes(m.tobytes())
841 else:
842 self.save_bytearray(m.tobytes())
843 else:
844 # Write data out-of-band
845 self.write(NEXT_BUFFER)
846 if m.readonly:
847 self.write(READONLY_BUFFER)
848
849 dispatch[PickleBuffer] = save_picklebuffer
850

Callers

nothing calls this directly

Calls 5

save_bytesMethod · 0.95
save_bytearrayMethod · 0.95
PicklingErrorClass · 0.85
rawMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected