summaryrefslogtreecommitdiffstats
path: root/Lib/pickletools.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pickletools.py')
-rw-r--r--Lib/pickletools.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index 408c2ac..8486cbf 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -2279,7 +2279,7 @@ def optimize(p):
if arg > proto:
proto = arg
if pos == 0:
- protoheader = p[pos: end_pos]
+ protoheader = p[pos:end_pos]
else:
opcodes.append((pos, end_pos))
else:
@@ -2295,6 +2295,7 @@ def optimize(p):
pickler.framer.start_framing()
idx = 0
for op, arg in opcodes:
+ frameless = False
if op is put:
if arg not in newids:
continue
@@ -2305,8 +2306,12 @@ def optimize(p):
data = pickler.get(newids[arg])
else:
data = p[op:arg]
- pickler.framer.commit_frame()
- pickler.write(data)
+ frameless = len(data) > pickler.framer._FRAME_SIZE_TARGET
+ pickler.framer.commit_frame(force=frameless)
+ if frameless:
+ pickler.framer.file_write(data)
+ else:
+ pickler.write(data)
pickler.framer.end_framing()
return out.getvalue()