Same as previous commits. "".join() is better that "string" + "another_string" + "another_string_2", because strings are immutable.
Also, changed for loops with list comprehension. This is much faster and would improve performance.
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
The variable sorting can have only 1 value at a time. So does not make sense to ask on every if statement the value of sorting. If one statement is True, then, the other would be False.
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
This will improve code execution because nested loops are slower than list/dictionary comprehensions.
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
This may seems like a lot, but the only think that I change here was the if/else block. I move the else statement at the beginning and if that condition is true, will exit the function. This is just for code clarity, I think that this change should not improve the speed or performance of the code.
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
This will remove the unnecesary import of time, and a little bit of format
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
This will make it easier for us to maintain and understand the main function. Also deleting duplicated code
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
Strings in Python are immutable so, the "+" operation means that we need to create the string again and attaching the old content. Per "+". We can replace this by using join() or built-in functions or arguments of functions, like "sep" in print()
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
According PEP8 this is the recommended way to do it. I'm 99% sure that this does not speed up the code, but we are comparing identity, not equality, so "is" and "is not" must be used.
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>