diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-02-11 21:06:20 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-02-11 21:06:20 (GMT) |
commit | 1092d640021ae8c572e77d8f377f531fc5291aea (patch) | |
tree | 58fed91663b21948b640485d04d955bc1ddc704d /Lib | |
parent | eea4718e814b8ec054557aa87d6c122305bf6f0b (diff) | |
download | cpython-1092d640021ae8c572e77d8f377f531fc5291aea.zip cpython-1092d640021ae8c572e77d8f377f531fc5291aea.tar.gz cpython-1092d640021ae8c572e77d8f377f531fc5291aea.tar.bz2 |
Implemented list batching in cPickle.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/pickle.py | 1 | ||||
-rw-r--r-- | Lib/test/pickletester.py | 34 |
2 files changed, 18 insertions, 17 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index 8431c41..0173c1f 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -612,6 +612,7 @@ class Pickler: dispatch[ListType] = save_list + # Keep in synch with cPickle's BATCHSIZE. _BATCHSIZE = 1000 def _batch_appends(self, items): diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index b161dd5..6ed29b1 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -672,23 +672,6 @@ class AbstractPickleTests(unittest.TestCase): self.produce_global_ext(0x7fffffff, pickle.EXT4) # largest EXT4 code self.produce_global_ext(0x12abcdef, pickle.EXT4) # check endianness -# XXX Temporary hack, so long as the C implementation of pickle protocol -# XXX 2 isn't ready. When it is, move the methods in TempAbstractPickleTests -# XXX into AbstractPickleTests above, and get rid of TempAbstractPickleTests -# XXX along with the references to it in test_pickle.py. -class TempAbstractPickleTests(unittest.TestCase): - - def test_newobj_list_slots(self): - x = SlotList([1, 2, 3]) - x.foo = 42 - x.bar = "hello" - s = self.dumps(x, 2) - y = self.loads(s) - self.assertEqual(list(x), list(y)) - self.assertEqual(x.__dict__, y.__dict__) - self.assertEqual(x.foo, y.foo) - self.assertEqual(x.bar, y.bar) - def test_list_chunking(self): n = 10 # too small to chunk x = range(n) @@ -711,6 +694,23 @@ class TempAbstractPickleTests(unittest.TestCase): else: self.failUnless(num_appends >= 2) +# XXX Temporary hack, so long as the C implementation of pickle protocol +# XXX 2 isn't ready. When it is, move the methods in TempAbstractPickleTests +# XXX into AbstractPickleTests above, and get rid of TempAbstractPickleTests +# XXX along with the references to it in test_pickle.py. +class TempAbstractPickleTests(unittest.TestCase): + + def test_newobj_list_slots(self): + x = SlotList([1, 2, 3]) + x.foo = 42 + x.bar = "hello" + s = self.dumps(x, 2) + y = self.loads(s) + self.assertEqual(list(x), list(y)) + self.assertEqual(x.__dict__, y.__dict__) + self.assertEqual(x.foo, y.foo) + self.assertEqual(x.bar, y.bar) + def test_dict_chunking(self): n = 10 # too small to chunk x = dict.fromkeys(range(n)) |