it is. But inbuilt iterators are faster than your own loops. Python generators and iterators are written inside interpreter and are much more efficient.
I tested it out.
This Version for long text: 0.0077
Version with my custom loop: 0.0256
if I understand correctly, then in the worst case, here at each iteration up to 6 (3 in condition and 3 in replace) searches are performed on the input string. Looks cool but too much IMO
it is. But inbuilt iterators are faster than your own loops. Python generators and iterators are written inside interpreter and are much more efficient.
I tested it out.
This Version for long text: 0.0077
Version with my custom loop: 0.0256
...
if I understand correctly, then in the worst case, here at each iteration up to 6 (3 in condition and 3 in replace) searches are performed on the input string. Looks cool but too much IMO
This comment is hidden because it contains spoiler information about the solution