Message165718
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 |
|
Date |
User |
Action |
Args |
2012-07-17 13:26:49 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ncoghlan, pitrou, eli.bendersky, tshepang |
2012-07-17 13:26:49 | serhiy.storchaka | set | messageid: <1342531609.27.0.26310866861.issue15381@psf.upfronthosting.co.za> |
2012-07-17 13:26:48 | serhiy.storchaka | link | issue15381 messages |
2012-07-17 13:26:48 | serhiy.storchaka | create | |
|