pickle alternative
Andrew Dalke
dalke at dalkescientific.com
Tue May 31 21:41:34 EDT 2005
simonwittber wrote:
> marshal can serialize small structures very qucikly, however, using the
> below test value:
>
> value = [r for r in xrange(1000000)] +
> [{1:2,3:4,5:6},{"simon":"wittber"}]
>
> marshal took 7.90 seconds to serialize it into a 5000061 length string.
> decode took 0.08 seconds.
Strange. Here's what I found:
>>> value = [r for r in xrange(1000000)] +[{1:2,3:4,5:6},{"simon":"wittber"}]
>>> import time, marshal
>>> t1=time.time();s=marshal.dumps(value);t2=time.time()
>>> t2-t1
0.22474002838134766
>>> len(s)
5000061
>>> t1=time.time();new_value=marshal.loads(s);t2=time.time()
>>> t2-t1
0.3606879711151123
>>> new_value == value
True
>>>
I can't reproduce your large times for marshal.dumps. Could you
post your test code?
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list