MCPcopy Index your code
hub / github.com/python/cpython / commit_frame

Method commit_frame

Lib/pickle.py:214–236  ·  view source on GitHub ↗
(self, force=False)

Source from the content-addressed store, hash-verified

212 self.current_frame = None
213
214 def commit_frame(self, force=False):
215 if self.current_frame:
216 f = self.current_frame
217 if f.tell() >= self._FRAME_SIZE_TARGET or force:
218 data = f.getbuffer()
219 write = self.file_write
220 if len(data) >= self._FRAME_SIZE_MIN:
221 # Issue a single call to the write method of the underlying
222 # file object for the frame opcode with the size of the
223 # frame. The concatenation is expected to be less expensive
224 # than issuing an additional call to write.
225 write(FRAME + pack("<Q", len(data)))
226
227 # Issue a separate call to write to append the frame
228 # contents without concatenation to the above to avoid a
229 # memory copy.
230 write(data)
231
232 # Start the new frame with a new io.BytesIO instance so that
233 # the file object can have delayed access to the previous frame
234 # contents via an unreleased memoryview of the previous
235 # io.BytesIO instance.
236 self.current_frame = io.BytesIO()
237
238 def write(self, data):
239 if self.current_frame:

Callers 4

end_framingMethod · 0.95
write_large_bytesMethod · 0.95
optimizeFunction · 0.80
saveMethod · 0.80

Calls 4

packFunction · 0.85
writeFunction · 0.70
tellMethod · 0.45
getbufferMethod · 0.45

Tested by

no test coverage detected