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

Method _batch_appends

Lib/pickle.py:1021–1055  ·  view source on GitHub ↗
(self, items, obj)

Source from the content-addressed store, hash-verified

1019 _BATCHSIZE = 1000
1020
1021 def _batch_appends(self, items, obj):
1022 # Helper to batch up APPENDS sequences
1023 save = self.save
1024 write = self.write
1025
1026 if not self.bin:
1027 for i, x in enumerate(items):
1028 try:
1029 save(x)
1030 except BaseException as exc:
1031 exc.add_note(f'when serializing {_T(obj)} item {i}')
1032 raise
1033 write(APPEND)
1034 return
1035
1036 start = 0
1037 for batch in batched(items, self._BATCHSIZE):
1038 batch_len = len(batch)
1039 if batch_len != 1:
1040 write(MARK)
1041 for i, x in enumerate(batch, start):
1042 try:
1043 save(x)
1044 except BaseException as exc:
1045 exc.add_note(f'when serializing {_T(obj)} item {i}')
1046 raise
1047 write(APPENDS)
1048 else:
1049 try:
1050 save(batch[0])
1051 except BaseException as exc:
1052 exc.add_note(f'when serializing {_T(obj)} item {start}')
1053 raise
1054 write(APPEND)
1055 start += batch_len
1056
1057 def save_dict(self, obj):
1058 if self.bin:

Callers 2

save_reduceMethod · 0.95
save_listMethod · 0.95

Calls 5

enumerateFunction · 0.85
_TFunction · 0.85
lenFunction · 0.85
add_noteMethod · 0.80
writeFunction · 0.70

Tested by

no test coverage detected