Antoine Pitrou <pit...@free.fr> added the comment: Here is a patch. Benchmark numbers:
* dumps(): ./python -m timeit -s "import pickle, io; d={(x, 'a'): x for x in range(10000)}" "pickle.dumps(d)" -> before: 100 loops, best of 3: 7.47 msec per loop -> after: 100 loops, best of 3: 2.45 msec per loop * loads(): ./python -m timeit -s "import pickle, io; d={(x, 'a'): x for x in range(10000)}; d=pickle.dumps(d)" "pickle.loads(d)" -> before: 100 loops, best of 3: 12.1 msec per loop -> after: 100 loops, best of 3: 2.62 msec per loop * dump(): ./python -m timeit -s "import pickle, io; d={(x, 'a'): x for x in range(10000)}" "pickle.dump(d, io.BytesIO())" -> before: 100 loops, best of 3: 13.2 msec per loop -> after: 100 loops, best of 3: 2.54 msec per loop * load(): ./python -m timeit -s "import pickle, io; d={(x, 'a'): x for x in range(10000)}; d=pickle.dumps(d)" "pickle.load(io.BytesIO(d))" -> before: 100 loops, best of 3: 12.7 msec per loop -> after: 100 loops, best of 3: 11.6 msec per loop As you can see, load() doesn't really benefit from the buffering improvements. The three methods see quite massive speedups. ---------- Added file: http://bugs.python.org/file18778/pickle_optimizations4.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9410> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com