[Python-Dev] RFC: Add a new builtin strarray type to Python?

Victor Stinner victor.stinner at haypocalc.com
Mon Oct 3 15:31:23 CEST 2011


Le 03/10/2011 04:19, Victor Stinner a écrit :
> I restored this hack in Python 3.3 using PyUnicode_Append() in ceval.c and by
> optimizing PyUnicode_Append() (try to append in-place). str+=str is closer
> again to ''.join:
>
> str += str: 696 ms
> ''.join():  547 ms
>
> I disabled temporary the optimization for wstr string in PyUnicode_Resize()
> because of a bug. I disabled completly resize on Windows because of another
> bug.

Ok, bugs fixed, all "resize" optimizations are now enabled:

Python 3.3
str += str    : 119 ms
''.join()     : 130 ms
StringIO.join : 147 ms
StringBuilder : 404 ms
array('u')    : 979 ms

Hum, str+=str is now the fastest method, even faster than ''.join() !? 
It's maybe time to optimize str.join ;-)

Victor


More information about the Python-Dev mailing list