<div dir="ltr"><div><div><div><div><div><div><span style="font-family:courier new,monospace">Hi,<br><br></span></div><span style="font-family:courier new,monospace">I tested the latest beta from 3.4 (b3) and noticed there is a new marshal protocol version 3.<br>
</span></div><span style="font-family:courier new,monospace">The documentation is a little silent about the new features, not going into detail.<br><br></span></div><span style="font-family:courier new,monospace">I've run a performance test with the new protocol version and noticed the new version is two times slower in serialization than version 2. I tested it with a simple value tuple in a list (500000 elements).<br>
</span></div><span style="font-family:courier new,monospace">Nothing special. (happens only if the tuple contains also a tuple)<br><br></span></div><div><span style="font-family:courier new,monospace">Copy of the test code:<br>
<br><br>from time import time<br>from marshal import dumps<br><br>def genData(amount=500000):<br> for i in range(amount):<br> yield (i, i+2, i*2, (i+1,i+4,i,4), "my string template %s" % i, 1.01*i, True)<br>
<br>data = list(genData())<br>print(len(data))<br>t0 = time()<br>result = dumps(data, 2)<br>t1 = time()<br>print("duration p2: %f" % (t1-t0))<br>t0 = time()<br>result = dumps(data, 3)<br>t1 = time()<br>print("duration p3: %f" % (t1-t0))<br>
</span></div><div><span style="font-family:courier new,monospace"><br><br><br></span></div><span style="font-family:courier new,monospace">Is the overhead for the recursion detection so high ?<br></span></div><span style="font-family:courier new,monospace"><br clear="all">
</span><div><div><div><div><div><div><div><div><div><span style="font-family:courier new,monospace">Note this happens only if there is a tuple in the tuple of the datalist.<br></span></div><div><span style="font-family:courier new,monospace"><br>
</span></div><div><span style="font-family:courier new,monospace"><br></span></div><div><span style="font-family:courier new,monospace">Regards,<br><br>Wolfgang</span></div><br></div></div></div></div></div></div></div></div>
</div>