On Wed, Oct 23, 2019 at 11:47:04AM +1100, Chris Angelico wrote:
This could be done as an optimization without changing syntax or semantics.. As long as the initial string is provided as a literal, it should be possible to call the method at compile time, since (as far as I know) every string method is a pure function.
Sure, it could be done as an optimization, similar to one of the proposals here:
It could also be done by a source code preprocessor, or an AST transformation, without changing syntax.
But the advantage of changing the syntax is that it becomes the One Obvious Way, and you know it will be efficient whatever version or implementation of Python you are using.