This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kristjan.jonsson
Recipients kristjan.jonsson, pitrou, vstinner
Date 2013-10-13.22:30:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1381703408.57.0.928931596293.issue19256@psf.upfronthosting.co.za>
In-reply-to
Content
Issue $19219 added new tokens making marshal format smaller and faster.
This patch adds two new tokens:
TYPE_SHORT_REF for which the ref index is a byte and
TYPE_VERSION for which the operand is the protocol version.

The former helps because it catches common singletons such as 0, 1, () and so on which typically show up early in a pickle.  they then need only two bytes to encoded.
This shrinks the code for the decimal.py module from 172K to 162K.


The second can help break backwards compatibility requirements in the future.  The format (if 4 or larger) is now put into the stream, so that future new formats can re-assign opcodes if needed.

I don't reassign the version number, leaving it at the new value of 4.  This change is still backwards compatible with the previous '4' so there should be no problem.

For size / performance comparison, try:
python.exe -m timeit -s "import decimal; c=compile(open(decimal.__file__).read(), decimal.__file__, 'exec'); import marshal; d=marshal.dumps(c); print(len(d))" "marshal.loads(d)"
History
Date User Action Args
2013-10-13 22:30:08kristjan.jonssonsetrecipients: + kristjan.jonsson, pitrou, vstinner
2013-10-13 22:30:08kristjan.jonssonsetmessageid: <1381703408.57.0.928931596293.issue19256@psf.upfronthosting.co.za>
2013-10-13 22:30:08kristjan.jonssonlinkissue19256 messages
2013-10-13 22:30:08kristjan.jonssoncreate