[Python-checkins] cpython: Issue #19754: Make pickletools.optimize respect the frame size target.

alexandre.vassalotti python-checkins at python.org
Mon Dec 2 01:28:00 CET 2013


http://hg.python.org/cpython/rev/bb71baa28f1b
changeset:   87684:bb71baa28f1b
user:        Alexandre Vassalotti <alexandre at peadrop.com>
date:        Sun Dec 01 16:27:46 2013 -0800
summary:
  Issue #19754: Make pickletools.optimize respect the frame size target.

files:
  Lib/pickletools.py           |   1 +
  Lib/test/pickletester.py     |  13 +------------
  Lib/test/test_pickletools.py |   2 --
  3 files changed, 2 insertions(+), 14 deletions(-)


diff --git a/Lib/pickletools.py b/Lib/pickletools.py
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -2313,6 +2313,7 @@
         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()
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1343,12 +1343,6 @@
                 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 @@
                 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:
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py
--- a/Lib/test/test_pickletools.py
+++ b/Lib/test/test_pickletools.py
@@ -6,8 +6,6 @@
 
 class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
 
-    optimized = True
-
     def dumps(self, arg, proto=None):
         return pickletools.optimize(pickle.dumps(arg, proto))
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list