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 rhettinger
Recipients alexandre.vassalotti, irmen, pitrou, python-dev, rhettinger
Date 2013-05-06.01:15:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1367802922.23.0.218055772731.issue13503@psf.upfronthosting.co.za>
In-reply-to
Content
Reopening this one because there is a size issue, not just speed.

My clients are bumping into this issue repeatedly.  There is a reasonable expectation that pickling a bytearray will result in a pickle about the same size as the bytearray (not a 50% to 100% expansion depending on the content).  Likewise, the size shouldn't double when switching from protocol 0 to the presumably more efficient protocol 2:

    >>> # Example using Python 2.7.4 on Mac OS X 10.8
    >>> from pickle import dumps
    >>> print len(dumps(bytearray([200] * 10000), 0))
    10055
    >>> print len(dumps(bytearray([200] * 10000), 2))
    20052
    >>> print len(dumps(bytearray([100] * 10000), 2))
    10052
    >>> print len(dumps(bytearray([100, 200] * 5000), 2))
    15052

An attractive feature of bytearrays are their compact representation of data.  An attractive feature of the binary pickle protocol is improved compactness and speed.  Currently, it isn't living up to expectations.
History
Date User Action Args
2013-05-06 01:15:22rhettingersetrecipients: + rhettinger, irmen, pitrou, alexandre.vassalotti, python-dev
2013-05-06 01:15:22rhettingersetmessageid: <1367802922.23.0.218055772731.issue13503@psf.upfronthosting.co.za>
2013-05-06 01:15:22rhettingerlinkissue13503 messages
2013-05-06 01:15:21rhettingercreate