Categories
Uncategorized

Python string concatination speed

I made a quick python script to convert OpenLP song (lyric) databases into the presentation format used by ProPresenter.

https://github.com/danthedeckie/OpenLP-To-ProPresenter5-Converter

is the link.  I put it together in a few hours, it should have been quicker, but I’m still re-acquainting myself with python.

It is a nice language.

One thing I did today, while cleaning up a bit, was wonder about something I remember from doing python years ago – string concatenation.  Joining two strings (texts) together.

“Hello” + “World” -> “HelloWorld”

I remembered something about it being slow, and python recommending using

”.join((“Hello”, “World”))

which seems to me one of the most blatently ugly obscure gotchas I’ve come across in a long while.

Anyway, I refactored my code into that style – converting databases and song lyrics and writing XML stuff is pretty much all Text formatting and concatination.

It made no discernable difference.  So I went back to normal easier to read x += y, and x = y + z type of code.