jython and concatenation of strings

Diez B. Roggisch deetsNOSPAM at web.de
Mon Dec 13 12:01:57 EST 2004


>  I found that price of += operator on string is too high in jython. For
>  example 5000 such operations took 90 seconds (i generated html copy of
>  table with 1000 rows and 5 columns). Generation of row data into separate
>  string and joining after lead to time 13 seconds !!!

Its generally not recommended to use simple string concatenation for
building larger strings - neither in python nor in java/jython.

afaik there are two solutions to this: The java-way and the jython way:

java: Use StringBuffer
python: use a list, and append the strings to that. Then, when you want the
result, do

"".join(stringlist)

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list