[New-bugs-announce] [issue17747] Deprecate pickle fast mode

Alexandre Vassalotti report at bugs.python.org
Tue Apr 16 11:20:07 CEST 2013


New submission from Alexandre Vassalotti:

Pickle fast mode is currently a deprecated feature of the Pickler class used to disable its memoization mechanism. It was used mainly to create smaller output by not emitting a PUT opcode for each object saved. Unfortunately, this mode only worked with non-cyclic data structures. If it encounters a such structure, this will result in a recursion exceed error (or a stack overflow if we are unlucky).

However, if correctly used, the fast mode is indeed faster.

./perf.py -b fastpickle ../cpython/python.exe ../fastmode/python.exe
Running fastpickle...
INFO:root:Running ../fastmode/python.exe ./performance/bm_pickle.py -n 50 --use_cpickle pickle
INFO:root:Running ../cpython/python.exe ./performance/bm_pickle.py -n 50 --use_cpickle pickle

Report on Darwin avassalotti.local 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64 i386
Total CPU cores: 4

### fastpickle ###
Min: 0.588284 -> 0.466613: 1.26x faster
Avg: 0.599152 -> 0.476224: 1.26x faster
Significant (t=70.69)
Stddev: 0.00862 -> 0.00877: 1.0173x larger
Timeline: http://tinyurl.com/btrxdm9

Anyhow, I am not convinced the mode is worth keeping for such limited use cases. The feature was undocumented throughout Python 2.x. So it found very few users if any. And it has currently no test coverage at all. So, in my opinion, the feature is at moment more a maintenance burden than anything else.

Now, if we are to deprecate it, I propose we change fast mode to do nothing and leave the 'fast' attribute on Pickler to not break any code that might use it. We should also emit a warning whenever the attribute is set.

----------
assignee: alexandre.vassalotti
components: Library (Lib)
keywords: needs review
messages: 187059
nosy: alexandre.vassalotti, pitrou, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Deprecate pickle fast mode
type: behavior
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17747>
_______________________________________


More information about the New-bugs-announce mailing list