Message165795
Here is a preliminary version of the patch. I am not sure that it is fully correct.
Microbenchmark results:
$ ./python -m timeit -s "import io; n=100; d=['a'*n,'bb'*n,'ccc'*n]*10000" "s=io.StringIO(); w=s.write" "for x in d: w(x)" "s.getvalue()"
10 loops, best of 3: 25.5 msec per loop
$ ./python -m timeit -s "import io; n=100; d=[b'a'*n,b'bb'*n,b'ccc'*n]*10000" "s=io.BytesIO(); w=s.write" "for x in d: w(x)" "s.getvalue()"
10 loops, best of 3: 39.9 msec per loop
$ ./python-patched -m timeit -s "import io; n=100; d=[b'a'*n,b'bb'*n,b'ccc'*n]*10000" "s=io.BytesIO(); w=s.write" "for x in d: w(x)" "s.getvalue()"
10 loops, best of 3: 26.1 msec per loop
$ ./python -m timeit -s "import io; n=1000; d=['a'*n,'bb'*n,'ccc'*n]*1000" "s=io.StringIO(); w=s.write" "for x in d: w(x)" "s.getvalue()"
100 loops, best of 3: 12.1 msec per loop
$ ./python -m timeit -s "import io; n=1000; d=[b'a'*n,b'bb'*n,b'ccc'*n]*1000" "s=io.BytesIO(); w=s.write" "for x in d: w(x)" "s.getvalue()"
10 loops, best of 3: 26.5 msec per loop
$ ./python-patched -m timeit -s "import io; n=1000; d=[b'a'*n,b'bb'*n,b'ccc'*n]*1000" "s=io.BytesIO(); w=s.write" "for x in d: w(x)" "s.getvalue()"
100 loops, best of 3: 13.6 msec per loop |
|
Date |
User |
Action |
Args |
2012-07-18 20:06:29 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ncoghlan, pitrou, Arfrever, eli.bendersky, tshepang, jcon |
2012-07-18 20:06:28 | serhiy.storchaka | set | messageid: <1342641988.81.0.408709732481.issue15381@psf.upfronthosting.co.za> |
2012-07-18 20:06:28 | serhiy.storchaka | link | issue15381 messages |
2012-07-18 20:06:27 | serhiy.storchaka | create | |
|