Message188480
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. |
|
Date |
User |
Action |
Args |
2013-05-06 01:15:22 | rhettinger | set | recipients:
+ rhettinger, irmen, pitrou, alexandre.vassalotti, python-dev |
2013-05-06 01:15:22 | rhettinger | set | messageid: <1367802922.23.0.218055772731.issue13503@psf.upfronthosting.co.za> |
2013-05-06 01:15:22 | rhettinger | link | issue13503 messages |
2013-05-06 01:15:21 | rhettinger | create | |
|