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

Method fast_save_enter

Lib/test/pickletester.py:4557–4575  ·  view source on GitHub ↗
(self, create_data, minprotocol=0)

Source from the content-addressed store, hash-verified

4555 self.assertIn(expected, str(e))
4556
4557 def fast_save_enter(self, create_data, minprotocol=0):
4558 # gh-146059: Check that fast_save_leave() is called when
4559 # fast_save_enter() is called.
4560 if not hasattr(self, "pickler"):
4561 self.skipTest("need Pickler class")
4562
4563 data = [create_data(i) for i in range(FAST_NESTING_LIMIT * 2)]
4564 protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1)
4565 for proto in protocols:
4566 with self.subTest(proto=proto):
4567 buf = io.BytesIO()
4568 pickler = self.pickler(buf, protocol=proto)
4569 # Enable fast mode (disables memo, enables cycle detection)
4570 pickler.fast = 1
4571 pickler.dump(data)
4572
4573 buf.seek(0)
4574 data2 = self.unpickler(buf).load()
4575 self.assertEqual(data2, data)
4576
4577 def test_fast_save_enter_tuple(self):
4578 self.fast_save_enter(lambda i: (i,))

Calls 7

seekMethod · 0.95
create_dataFunction · 0.85
skipTestMethod · 0.80
subTestMethod · 0.45
dumpMethod · 0.45
loadMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected