Serhiy Storchaka <storch...@gmail.com> added the comment: 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 ---------- keywords: +patch Added file: http://bugs.python.org/file26429/bytesio_resized_bytes.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15381> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com