Python strings

Found a neat discussion of the relative efficiencies of various methods of string concatenation in Python. Turns out the most concise method is also the most efficient. The trick is to build a list, and join the entire list together to make a string at the end, rather than have to allocate a new string every time you add to the end of it (strings in Python are immutable).http://www.skymind.com/~ocrow/python_string/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: