diff options
author | Olivier Grisel <olivier.grisel@ensta.org> | 2018-01-06 15:18:54 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-01-06 15:18:54 (GMT) |
commit | 3cd7c6e6eb43dbd7d7180503265772a67953e682 (patch) | |
tree | 7f09aaed6d17611ef6904591525d74de89f854e9 /Lib/test/test_pickletools.py | |
parent | 85ac726a40707ae68a23d568c322868e353217ce (diff) | |
download | cpython-3cd7c6e6eb43dbd7d7180503265772a67953e682.zip cpython-3cd7c6e6eb43dbd7d7180503265772a67953e682.tar.gz cpython-3cd7c6e6eb43dbd7d7180503265772a67953e682.tar.bz2 |
bpo-31993: Do not allocate large temporary buffers in pickle dump. (#4353)
The picklers do no longer allocate temporary memory when dumping large
bytes and str objects into a file object. Instead the data is
directly streamed into the underlying file object.
Previously the C implementation would buffer all content and issue a
single call to file.write() at the end of the dump. With protocol 4
this behavior has changed to issue one call to file.write() per frame.
The Python pickler with protocol 4 now dumps each frame content as a
memoryview to an IOBytes instance that is never reused and the
memoryview is no longer released after the call to write. This makes it
possible for the file object to delay access to the memoryview of
previous frames without forcing any additional memory copy as was
already possible with the C pickler.
Diffstat (limited to 'Lib/test/test_pickletools.py')
-rw-r--r-- | Lib/test/test_pickletools.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py index b3cab0e..e40a958 100644 --- a/Lib/test/test_pickletools.py +++ b/Lib/test/test_pickletools.py @@ -15,6 +15,9 @@ class OptimizedPickleTests(AbstractPickleTests): # Test relies on precise output of dumps() test_pickle_to_2x = None + # Test relies on writing by chunks into a file object. + test_framed_write_sizes_with_delayed_writer = None + def test_optimize_long_binget(self): data = [str(i) for i in range(257)] data.append(data[-1]) |