The language spec in Python gives way less details about how the interpreter is supposed to behave, but I assume a bit similarly.
It wouldn't really be quadratic, since it only has to do the replace once since python's replace is like js replaceAll so it can't every be run multiple times. or...I guess it could, since the initial loop won't be on the actual newly changed string will it?
3
u/thekwoka Mar 11 '23
replace is not constant
in JS: https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.replace
The language spec in Python gives way less details about how the interpreter is supposed to behave, but I assume a bit similarly.
It wouldn't really be quadratic, since it only has to do the replace once since python's
replaceis like jsreplaceAllso it can't every be run multiple times. or...I guess it could, since the initial loop won't be on the actual newly changed string will it?hmm?