I have a list called L inside a loop that must iterate though millions of lines. The salient features are:
for line in lines:
L = ['a', 'list', 'with', 'lots', 'of', 'items']
L[3] = 'prefix_text_to_item3' + L[3]
Do more stuff with L...
Is there a better approach to adding text to a list item that would speed up my code. Can .join be used? Thanks.
In a performance oriented code, it is not a good idea to add 2 strings together, it is preferable to use a
"".join(_items2join_)instead. (I found some benchmarks there : http://www.skymind.com/~ocrow/python_string/)