From 1211c9a9897a174b7261ca258cabf289815a40d8 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 20 Jan 2018 16:42:44 +0200 Subject: bpo-32503: Avoid creating too small frames in pickles. (#5127) --- Lib/pickle.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Lib/pickle.py') diff --git a/Lib/pickle.py b/Lib/pickle.py index 301e8cf558..e6d003787b 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -183,6 +183,7 @@ __all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$", x)]) class _Framer: + _FRAME_SIZE_MIN = 4 _FRAME_SIZE_TARGET = 64 * 1024 def __init__(self, file_write): @@ -203,11 +204,12 @@ class _Framer: if f.tell() >= self._FRAME_SIZE_TARGET or force: data = f.getbuffer() write = self.file_write - # Issue a single call to the write method of the underlying - # file object for the frame opcode with the size of the - # frame. The concatenation is expected to be less expensive - # than issuing an additional call to write. - write(FRAME + pack("= self._FRAME_SIZE_MIN: + # Issue a single call to the write method of the underlying + # file object for the frame opcode with the size of the + # frame. The concatenation is expected to be less expensive + # than issuing an additional call to write. + write(FRAME + pack("