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

Method _batch_setitems

tools/python-3.11.9-amd64/Lib/pickle.py:978–1007  ·  view source on GitHub ↗
(self, items)

Source from the content-addressed store, hash-verified

976 dispatch[PyStringMap] = save_dict
977
978 def _batch_setitems(self, items):
979 # Helper to batch up SETITEMS sequences; proto >= 1 only
980 save = self.save
981 write = self.write
982
983 if not self.bin:
984 for k, v in items:
985 save(k)
986 save(v)
987 write(SETITEM)
988 return
989
990 it = iter(items)
991 while True:
992 tmp = list(islice(it, self._BATCHSIZE))
993 n = len(tmp)
994 if n > 1:
995 write(MARK)
996 for k, v in tmp:
997 save(k)
998 save(v)
999 write(SETITEMS)
1000 elif n:
1001 k, v = tmp[0]
1002 save(k)
1003 save(v)
1004 write(SETITEM)
1005 # else tmp is empty, and we're done
1006 if n < self._BATCHSIZE:
1007 return
1008
1009 def save_set(self, obj):
1010 save = self.save

Callers 2

save_reduceMethod · 0.95
save_dictMethod · 0.95

Calls 2

listFunction · 0.85
writeFunction · 0.70

Tested by

no test coverage detected