]> granicus.if.org Git - python/commitdiff
Issue #19754: Make pickletools.optimize respect the frame size target.
authorAlexandre Vassalotti <alexandre@peadrop.com>
Mon, 2 Dec 2013 00:27:46 +0000 (16:27 -0800)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Mon, 2 Dec 2013 00:27:46 +0000 (16:27 -0800)
Lib/pickletools.py
Lib/test/pickletester.py
Lib/test/test_pickletools.py

index 74b65cea71756612072311021341ddd648e98409..a1c3f1316214609a5a684180c69399abfc4c53fd 100644 (file)
@@ -2313,6 +2313,7 @@ def optimize(p):
         buf.start_framing()
     for start, stop, putid in opcodes:
         if putid in gets:
+            #buf.commit_frame()
             buf.write(p[start:stop])
     if proto >= 4:
         buf.end_framing()
index 999eab0d5cbb81973efb0dab27b1525a45ab15f4..d07bc9217770a1623f8de784eee9af88342a4e81 100644 (file)
@@ -1343,12 +1343,6 @@ class AbstractPickleTests(unittest.TestCase):
                 pickled = self.dumps(obj, proto)
                 unpickled = self.loads(pickled)
                 self.assertEqual(obj, unpickled)
-                # Test the framing heuristic is sane,
-                # assuming a given frame size target.
-                if self.optimized:
-                    # These assumptions are currently invalid for optimized
-                    # pickles (see e.g. issue19754).
-                    continue
                 bytes_per_frame = (len(pickled) /
                                    count_opcode(pickle.FRAME, pickled))
                 self.assertGreater(bytes_per_frame,
@@ -1365,12 +1359,7 @@ class AbstractPickleTests(unittest.TestCase):
                 unpickled = self.loads(pickled)
                 self.assertEqual(obj, unpickled)
                 n_frames = count_opcode(pickle.FRAME, pickled)
-                if self.optimized:
-                    # At least one frame was emitted (see issue19754).
-                    self.assertGreaterEqual(n_frames, 1)
-                else:
-                    # At least one frame was emitted per large bytes object.
-                    self.assertGreaterEqual(n_frames, len(obj))
+                self.assertGreaterEqual(n_frames, len(obj))
 
     def test_optional_frames(self):
         if pickle.HIGHEST_PROTOCOL < 4:
index 029b5b1d51c3b760c5f4d4ac9f66e3838ffe4c47..d37ac263c4c14f3f3bc645ab78446d93a75a3001 100644 (file)
@@ -6,8 +6,6 @@ from test.pickletester import AbstractPickleModuleTests
 
 class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
 
-    optimized = True
-
     def dumps(self, arg, proto=None):
         return pickletools.optimize(pickle.dumps(arg, proto))