Message166008
StringIO:
$ ./python -m timeit -s "import io; n=2000; d=['a'*n,'bb'*n,'ccc'*n]*1000" "s=io.StringIO(); w=s.write" "for x in d: w(x)" "global y; y = s.getvalue()"
-> Linux: 1000 loops, best of 3: 985 usec per loop
-> Windows: 100 loops, best of 3: 4.26 msec per loop
Unpatched BytesIO:
$ ./python -m timeit -s "import io; n=2000; d=[b'a'*n,b'bb'*n,b'ccc'*n]*1000" "s=io.BytesIO(); w=s.write" "for x in d: w(x)" "global y; y = s.getvalue()"
-> Linux: 100 loops, best of 3: 2.44 msec per loop
-> Windows: 10 loops, best of 3: 38.4 msec per loop
b''.join():
$ ./python -m timeit -s "import io; n=2000; d=[b'a'*n,b'bb'*n,b'ccc'*n]*1000" "l = list(d)" "global y; y = b''.join(l)"
-> Linux: 1000 loops, best of 3: 821 usec per loop
-> Windows: 100 loops, best of 3: 4.09 msec per loop
bytearray:
$ ./python -m timeit -s "import io; n=2000; d=[b'a'*n,b'bb'*n,b'ccc'*n]*1000" "b = bytearray()" "for x in d: b += x" "global y; y = b"
-> Linux: 1000 loops, best of 3: 834 usec per loop
-> Windows: 10 loops, best of 3: 37.8 msec per loop |
|
Date |
User |
Action |
Args |
2012-07-21 10:37:27 | pitrou | set | recipients:
+ pitrou, ncoghlan, Arfrever, eli.bendersky, meador.inge, tshepang, jcon, serhiy.storchaka |
2012-07-21 10:37:27 | pitrou | set | messageid: <1342867047.2.0.549556856417.issue15381@psf.upfronthosting.co.za> |
2012-07-21 10:37:26 | pitrou | link | issue15381 messages |
2012-07-21 10:37:26 | pitrou | create | |
|