CodeQL queries 1.24
If you concatenate strings in a loop then the time taken by the loop is quadratic in the number of iterations.
Initialize an empty list before the start of the list.
During the loop append the substrings to the list.
At the end of the loop, convert the list to a string by using
- Python Standard Library: The str.join method.
- Python Frequently Asked Questions: What is the most efficient way to concatenate many strings together?.