This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients eli.bendersky, ncoghlan, pitrou, serhiy.storchaka, tshepang
Date 2012-07-17.13:26:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342531609.27.0.26310866861.issue15381@psf.upfronthosting.co.za>
In-reply-to
Content
I am not see that BytesIO is slower than StringIO (both are about 30% slower than append/join).

$ ./python -m timeit -s "import io; d=[b'a'*10,b'bb'*5,b'ccc'*5]*1000"  "b=[]; w=b.append"  "for x in d: w(x)"  "b''.join(b)"
1000 loops, best of 3: 966 usec per loop

$ ./python -m timeit -s "import io; d=['a'*10,'bb'*5,'ccc'*5]*1000"  "b=[]; w=b.append"  "for x in d: w(x)"  "''.join(b)"
1000 loops, best of 3: 918 usec per loop

$ ./python -m timeit -s "import io; d=[b'a'*10,b'bb'*5,b'ccc'*5]*1000"  "b=io.BytesIO(); w=b.write"  "for x in d: w(x)"  "b.getvalue()"
1000 loops, best of 3: 1.22 msec per loop

$ ./python -m timeit -s "import io; d=['a'*10,'bb'*5,'ccc'*5]*1000"  "b=io.StringIO(); w=b.write"  "for x in d: w(x)"  "b.getvalue()"
1000 loops, best of 3: 1.24 msec per loop
History
Date User Action Args
2012-07-17 13:26:49serhiy.storchakasetrecipients: + serhiy.storchaka, ncoghlan, pitrou, eli.bendersky, tshepang
2012-07-17 13:26:49serhiy.storchakasetmessageid: <1342531609.27.0.26310866861.issue15381@psf.upfronthosting.co.za>
2012-07-17 13:26:48serhiy.storchakalinkissue15381 messages
2012-07-17 13:26:48serhiy.storchakacreate